function _bootstrap_add_class

8.x-3.x deprecated.php _bootstrap_add_class($class, array &$element, $property = 'attributes')
7.x-3.x _bootstrap_add_class($class, array &$element, $property = 'attributes')

Adds a class to an element's render array.

  // Before.
  _bootstrap_add_class('my-class', $element);

  // After.
  use Drupal\bootstrap\Utility\Element;


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

array $element: The individual renderable array element. It is possible to also pass the $variables parameter in [pre]process functions and it will logically determine the correct path to that particular theme hook's classes array. Passed by reference.

string $property: Determines which attributes array to retrieve. By default, this is the element's normal "attributes", but it could also be one of the following:

  • "content_attributes"
  • "input_group_attributes"
  • "title_attributes"
  • "wrapper_attributes".


Will be removed in a future release.

Source ./deprecated.php (line 135)

function _bootstrap_add_class($class, array &$element, $property = 'attributes') {
  Element::create($element)->addClass($class, $property);