public function LayoutBuilderComponentRenderArray::onBuildRender in Layout Builder Component Attributes 1.2.x
Same name and namespace in other branches
- 1.0.x src/EventSubscriber/LayoutBuilderComponentRenderArray.php \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray::onBuildRender()
- 1.1.x src/EventSubscriber/LayoutBuilderComponentRenderArray.php \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray::onBuildRender()
Adds block classes to section component.
Parameters
\Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event: The section component render event.
File
- src/
EventSubscriber/ LayoutBuilderComponentRenderArray.php, line 28
Class
- LayoutBuilderComponentRenderArray
- Event subscriber to add classes when components are rendered.
Namespace
Drupal\layout_builder_component_attributes\EventSubscriberCode
public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
$build = $event
->getBuild();
if (!empty($build)) {
$build['#component_attributes'] = $event
->getComponent()
->get('component_attributes');
$event
->setBuild($build);
}
}