function Attribute::hasAttribute

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

Checks if the storage has an attribute with the given name.

Parameters

string $name: The name of the attribute to check for.

Return value

bool Returns TRUE if the attribute exists, or FALSE otherwise.

File

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

Class

Attribute
Collects, sanitizes, and renders HTML attributes.

Namespace

Drupal\Core\Template

Code

public function hasAttribute($name) {
    return array_key_exists($name, $this->storage);
}

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