public function ClassyLayout::build in Layout Section Classes 8
Build a render array for layout with regions.
Parameters
array $regions: An associative array keyed by region name, containing render arrays representing the content that should be placed in each region.
Return value
array Render array for the layout with regions.
Overrides LayoutDefault::build
File
- src/
ClassyLayout.php, line 17
Class
- ClassyLayout
- A layout plugin class for layouts with selectable classes.
Namespace
Drupal\layout_section_classesCode
public function build(array $regions) {
$build = parent::build($regions);
$classes = $this->configuration['additional']['classes'] ?? [];
$build['#attributes']['class'] = $build['#attributes']['class'] ?? [];
foreach ($classes as $class_set) {
if (is_string($class_set) && $class_set) {
$build['#attributes']['class'][] = $class_set;
}
if (is_array($class_set)) {
$build['#attributes']['class'] = array_merge($build['#attributes']['class'], array_filter($class_set));
}
}
return $build;
}