public static function ClaroPreRender::container in Drupal 8
Same name and namespace in other branches
- 9 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 137
Class
- ClaroPreRender
- Implements trusted prerender callbacks for the Claro theme.
Namespace
Drupal\claroCode
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;
}