Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClaroPreRender.php

function 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal