You are here

function _bootstrap_add_class in Express 8

Adds a class to an element's render array.

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

// After.
use Drupal\bootstrap\Utility\Element;
Element::create($element)
  ->addClass('my-class');

Parameters

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".

Deprecated

Will be removed in a future release.

See also

\Drupal\bootstrap\Utility\Element::addClass()

File

themes/contrib/bootstrap/deprecated.php, line 134
This contains deprecated functions that will be removed in a future release.

Code

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