function Attribute::toArray

Same name in other branches
  1. 9 core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::toArray()
  2. 10 core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::toArray()
  3. 11.x core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::toArray()

Returns all storage elements as an array.

Return value

array An associative array of attributes.

1 call to Attribute::toArray()
Attribute::merge in core/lib/Drupal/Core/Template/Attribute.php
Merges an Attribute object into the current storage.

File

core/lib/Drupal/Core/Template/Attribute.php, line 331

Class

Attribute
Collects, sanitizes, and renders HTML attributes.

Namespace

Drupal\Core\Template

Code

public function toArray() {
    $return = [];
    foreach ($this->storage as $name => $value) {
        $return[$name] = $value->value();
    }
    return $return;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.