function ThemeHooks::container

Same name and namespace in other branches
  1. main core/themes/admin/src/Hook/ThemeHooks.php \Drupal\admin\Hook\ThemeHooks::container()

Prerender callback for container elements.

Parameters

array $element: The container element.

Return value

array The processed container element.

File

core/themes/admin/src/Hook/ThemeHooks.php, line 379

Class

ThemeHooks
Provides theme related hook implementations.

Namespace

Drupal\admin\Hook

Code

public static function container(array $element) : array {
  if (!empty($element['#accordion'])) {
    // The container must work as an accordion list wrapper.
    $element['#attributes']['class'][] = 'accordion';
    $children_keys = Element::children($element['#groups']['advanced'], TRUE);
    foreach ($children_keys as $key) {
      $element['#groups']['advanced'][$key]['#attributes']['class'][] = 'accordion__item';
      // Mark children with type Details as accordion item.
      if (!empty($element['#groups']['advanced'][$key]['#type']) && $element['#groups']['advanced'][$key]['#type'] === 'details') {
        $element['#groups']['advanced'][$key]['#accordion_item'] = TRUE;
      }
    }
  }
  return $element;
}

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