class AttributeArray

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:

$attributes = new Attribute(array());
$attributes['class'] = array();
$attributes['class'][] = 'cat';

Incorrect:

$attributes = new Attribute(array());
$attributes['class'][] = 'cat';

Hierarchy

  • class \Drupal\Core\Template\AttributeValueBase
    • class \Drupal\Core\Template\AttributeArray implements \Drupal\Core\Template\ArrayAccess, \Drupal\Core\Template\IteratorAggregate

Expanded class hierarchy of AttributeArray

See also

Drupal\Core\Template\Attribute

File

drupal/core/lib/Drupal/Core/Template/AttributeArray.php, line 29
Definition of Drupal\Core\Template\AttributeArray.

Namespace

Drupal\Core\Template
View source

Members

Namesort descending Modifiers Type Description Overrides
AttributeArray::getIterator public function Implements IteratorAggregate::getIterator().
AttributeArray::offsetExists public function Implements ArrayAccess::offsetExists().
AttributeArray::offsetGet public function Implements ArrayAccess::offsetGet().
AttributeArray::offsetSet public function Implements ArrayAccess::offsetSet().
AttributeArray::offsetUnset public function Implements ArrayAccess::offsetUnset().
AttributeArray::value public function Returns the whole array.
AttributeArray::__toString public function Implements the magic __toString() method. Overrides AttributeValueBase::__toString
AttributeValueBase::$name protected property The name of the value.
AttributeValueBase::$printed protected property Whether this attribute hsa been printed already.
AttributeValueBase::$value protected property The value itself.
AttributeValueBase::printed public function Whether this attribute hsa been printed already.
AttributeValueBase::render public function Returns a string representation of the attribute. 1
AttributeValueBase::__construct public function Constructs a \Drupal\Core\Template\AttributeValueBase object.