function TwigExtension::createAttribute

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::createAttribute()
  2. 10 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::createAttribute()
  3. 11.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::createAttribute()

Creates an Attribute object.

Parameters

array $attributes: (optional) An associative array of key-value pairs to be converted to HTML attributes.

Return value

\Drupal\Core\Template\Attribute An attributes object that has the given attributes.

File

core/lib/Drupal/Core/Template/TwigExtension.php, line 620

Class

TwigExtension
A class providing Drupal Twig extensions.

Namespace

Drupal\Core\Template

Code

public function createAttribute(array $attributes = []) {
    return new Attribute($attributes);
}

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