AlterKeyTrait
Provides support for defining and initializing the default "alter key".
The alter key is used by alteration traits (e.g., AlterUrlPropertyTrait) to resolve which property or contextual key should be used when applying transformations in a model's alteration pipeline.
By default, the alter key is initialized to Schema::ID, but it can be overridden at construction time or during initialization using the ModelParam::ALTER_KEY parameter.
Tags
Table of Contents
Properties
- $alterKey : string
- The default property key used when an alteration needs to read a value from the document.
Methods
- initializeAlterKey() : static
- Initializes the {@see $alterKey} property from an initialization array.
Properties
$alterKey
The default property key used when an alteration needs to read a value from the document.
public
string
$alterKey
= \org\schema\constants\Schema::ID
Consumed for instance by AlterUrlPropertyTrait to pick which property provides the final URL segment when none is given explicitly. Defaults to Schema::ID.
Tags
Methods
initializeAlterKey()
Initializes the {@see $alterKey} property from an initialization array.
public
initializeAlterKey([array<string|int, mixed> $init = [] ]) : static
Reads ModelParam::ALTER_KEY from $init; when absent, the key falls back to
Schema::ID. Returns the current instance for fluent chaining.
Parameters
- $init : array<string|int, mixed> = []
-
Initialization options; the ModelParam::ALTER_KEY entry, when present, overrides the default alter key.
Tags
Return values
static —The current instance, for method chaining.