You are here

public function LayoutBuilderComponentRenderArray::onBuildRender in Layout Builder Component Attributes 1.2.x

Same name and namespace in other branches
  1. 1.0.x src/EventSubscriber/LayoutBuilderComponentRenderArray.php \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray::onBuildRender()
  2. 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\EventSubscriber

Code

public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
  $build = $event
    ->getBuild();
  if (!empty($build)) {
    $build['#component_attributes'] = $event
      ->getComponent()
      ->get('component_attributes');
    $event
      ->setBuild($build);
  }
}