function _bootstrap_get_classes

8.x-3.x deprecated.php &_bootstrap_get_classes(array &$element, $property = 'attributes')
7.x-3.x common.inc &_bootstrap_get_classes(array &$element, $property = 'attributes')

Retrieves an element's "class" array.

Parameters

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 normal attributes, but can be "wrapper_attributes" or "input_group_attributes".

Return value

array The classes array. Passed by reference.

Related topics

Source includes/common.inc (line 541)

function &_bootstrap_get_classes(array &$element, $property = 'attributes') {
  $attributes = &_bootstrap_get_attributes($element, $property);

  if (!isset($attributes['class'])) {
    $attributes['class'] = array();
  }
  // Contrib modules have a very bad habit of frequently adding classes as
  // strings, convert them to a proper array.
  // @see https://www.drupal.org/node/2269653
  elseif (!is_array($attributes['class'])) {
    $attributes['class'] = explode(' ', $attributes['class']);
  }

  // Ensure classes are not duplicated.
  $attributes['class'] = array_unique($attributes['class']);
  return $attributes['class'];
}