Skip to content

InitContextAttributeAccess

The attribute accessor cluster shared by Action and View: a facade over the attributes an execution’s init context holds, so an action or view reads and writes them without knowing where they live.

One rule governs every method. Reads answer from $localAttributes first and fall back to the init context’s holder; writes land in the local store whenever it exists, and go to the holder otherwise. A consumer therefore observes its own write through every reader, whichever accessor it used.

The local store exists for the container-less execution path, where the init context is an immutable snapshot that cannot be written to. Users that never populate it (an action) get holder-backed behaviour throughout, with no branch of their own.

trait InitContextAttributeAccess

Since3.2.0
SourceUtil/InitContextAttributeAccess.php
PropertyTypeDescription
$localAttributesmixedprotected. The consumer’s own mutable attribute store, or null when it has none and the init context’s holder is the only storage.
MethodDescription
appendAttribute(string $name, mixed $value): void
appendAttributeByRef(string $name, mixed &$value): void
clearAttributes(): void
getAttribute(string $name, mixed $default = null): mixed
[`getAttributeNames(): array<int, intstring>`](#getattributenames)
[`getAttributes(): array<intstring, mixed>`](#getattributes)
hasAttribute(string $name): bool
removeAttribute(string $name): mixed
setAttribute(string $name, mixed $value): void
setAttributeByRef(string $name, mixed &$value): void
[`setAttributes(array<intstring, mixed> $attributes): void`](#setattributes)
[`setAttributesByRef(array<intstring, mixed> &$attributes): void`](#setattributesbyref)

public function appendAttribute(string $name, mixed $value): void

An attribute value.

ParameterTypeDescription
$namestringAn attribute name.
$valuemixedAn attribute value.

public function appendAttributeByRef(string $name, mixed &$value): void

A reference to an attribute value.

ParameterTypeDescription
$namestringAn attribute name.
$valuemixedA reference to an attribute value.

public function clearAttributes(): void

public function getAttribute(string $name, mixed $default = null): mixed

A default attribute value.

ParameterTypeDescription
$namestringAn attribute name.
$defaultmixedA default attribute value.

Returns mixed

public function getAttributeNames(): array<int, int|string>

Returns array``<``int``, ``int``|``string``>

public function getAttributes(): array<int|string, mixed>

Returns array``<``int``|``string``, ``mixed``>

public function hasAttribute(string $name): bool

An attribute name.

ParameterTypeDescription
$namestringAn attribute name.

Returns bool

public function removeAttribute(string $name): mixed

An attribute name.

ParameterTypeDescription
$namestringAn attribute name.

Returns mixed — The removed value, or null when the name was not set.

public function setAttribute(string $name, mixed $value): void

An attribute value.

ParameterTypeDescription
$namestringAn attribute name.
$valuemixedAn attribute value.

public function setAttributeByRef(string $name, mixed &$value): void

A reference to an attribute value.

ParameterTypeDescription
$namestringAn attribute name.
$valuemixedA reference to an attribute value.

public function setAttributes(array<int|string, mixed> $attributes): void

ParameterTypeDescription
$attributes`array<int“string, mixed>`

public function setAttributesByRef(array<int|string, mixed> &$attributes): void

ParameterTypeDescription
$attributes`array<int“string, mixed>`