W3cubDocs

/Drupal 8

public function Attribute::toArray

public Attribute::toArray()

Returns all storage elements as an array.

Return value

array An associative array of attributes.

File

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

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Template!Attribute.php/function/Attribute::toArray/8.1.x