function public function Attributes::addClass

8.x-3.x Attributes.php public Attributes::addClass($class)

Add class(es) to the array.

Parameters

string|array $class: An individual class or an array of classes to add.

Class

Attributes
Class to help modify attributes.

Namespace

Drupal\bootstrap\Utility

Source src/Utility/Attributes.php (line 29)

public function addClass($class) {
  // Handle core Attribute based object values.
  // @see https://www.drupal.org/project/bootstrap/issues/3020266
  if ($class instanceof AttributeValueBase) {
    $class = $class->value();
  }
  $classes = &$this->getClasses();
  $classes = array_unique(array_merge($classes, (array) $class));
}