class AttributeArray extends AttributeValueBase implements ArrayAccess, IteratorAggregate (View source)

A class that defines a type of Attribute that can be added to as an array.

To use with Attribute, the array must be specified. Correct:

Constants

RENDER_EMPTY_ATTRIBUTE

Ensures empty array as a result of array_filter will not print '$name=""'.

Properties

protected mixed $value

The value itself.

from  AttributeValueBase
protected mixed $name

The name of the value.

from  AttributeValueBase

Methods

__construct($name, $value)

Constructs a \Drupal\Core\Template\AttributeValueBase object.

string
render()

Returns a string representation of the attribute.

value()

Returns the raw value.

__toString()

Implements the magic __toString() method.

offsetGet($offset)

{@inheritdoc}

offsetSet($offset, $value)

{@inheritdoc}

offsetUnset($offset)

{@inheritdoc}

offsetExists($offset)

{@inheritdoc}

getIterator()

{@inheritdoc}

array
exchangeArray(array $input)

Exchange the array for another one.

Details

__construct($name, $value)

Constructs a \Drupal\Core\Template\AttributeValueBase object.

Parameters

$name
$value

string render()

Returns a string representation of the attribute.

While __toString only returns the value in a string form, render() contains the name of the attribute as well.

Return Value

string

The string representation of the attribute.

value()

Returns the raw value.

__toString()

Implements the magic __toString() method.

offsetGet($offset)

{@inheritdoc}

Parameters

$offset

offsetSet($offset, $value)

{@inheritdoc}

Parameters

$offset
$value

offsetUnset($offset)

{@inheritdoc}

Parameters

$offset

offsetExists($offset)

{@inheritdoc}

Parameters

$offset

getIterator()

{@inheritdoc}

array exchangeArray(array $input)

Exchange the array for another one.

Parameters

array $input

The array input to replace the internal value.

Return Value

array

The old array value.

See also

ArrayObject::exchangeArray