function ClaroPreRender::container

Same name in other branches
  1. 9 core/themes/claro/src/ClaroPreRender.php \Drupal\claro\ClaroPreRender::container()
  2. 8.9.x core/themes/claro/src/ClaroPreRender.php \Drupal\claro\ClaroPreRender::container()
  3. 11.x core/themes/claro/src/ClaroPreRender.php \Drupal\claro\ClaroPreRender::container()

Prerender callback for container elements.

Parameters

array $element: The container element.

Return value

array The processed container element.

File

core/themes/claro/src/ClaroPreRender.php, line 134

Class

ClaroPreRender
Implements trusted prerender callbacks for the Claro theme.

Namespace

Drupal\claro

Code

public static function container(array $element) {
    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.