You are here

public function Attribute::hasClass in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 279
Contains \Drupal\Core\Template\Attribute.

Class

Attribute
Collects, sanitizes, and renders HTML attributes.

Namespace

Drupal\Core\Template

Code

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