Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TwigExtension.php

function TwigExtension::createAttribute

Creates an Attribute object.

Parameters

Attribute|array $attributes: (optional) An existing attribute object or 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 625

Class

TwigExtension
A class providing Drupal Twig extensions.

Namespace

Drupal\Core\Template

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal