function Attribute::getClass

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

Gets the class attribute value if set.

This method is implemented to take precedence over hasClass() for Twig 2.0.

Return value

\Drupal\Core\Template\AttributeValueBase The class attribute value if set.

See also

twig_get_attribute()

File

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

Class

Attribute
Collects, sanitizes, and renders HTML attributes.

Namespace

Drupal\Core\Template

Code

public function getClass() {
    return $this->offsetGet('class');
}

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