function Attribute::hasClass
Same name in other branches
- 9 core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::hasClass()
- 8.9.x core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::hasClass()
- 11.x core/lib/Drupal/Core/Template/Attribute.php \Drupal\Core\Template\Attribute::hasClass()
Checks if the class array has the given CSS class.
Parameters
string $class: The CSS class to check for.
Return value
bool Returns TRUE if the class exists, or FALSE otherwise.
File
-
core/
lib/ Drupal/ Core/ Template/ Attribute.php, line 310
Class
- Attribute
- Collects, sanitizes, and renders HTML attributes.
Namespace
Drupal\Core\TemplateCode
public function hasClass($class) {
if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) {
return in_array($class, $this->storage['class']
->value());
}
else {
return FALSE;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.