You are here

class LayoutBuilderComponentRenderArray in Layout Builder Component Attributes 1.1.x

Same name and namespace in other branches
  1. 1.2.x src/EventSubscriber/LayoutBuilderComponentRenderArray.php \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray
  2. 1.0.x src/EventSubscriber/LayoutBuilderComponentRenderArray.php \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray

Class LayoutBuilderComponentRenderArray.

Hierarchy

  • class \Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of LayoutBuilderComponentRenderArray

1 string reference to 'LayoutBuilderComponentRenderArray'
layout_builder_component_attributes.services.yml in ./layout_builder_component_attributes.services.yml
layout_builder_component_attributes.services.yml
1 service uses LayoutBuilderComponentRenderArray
layout_builder_component_attributes.section_component_build_render_array_subscriber in ./layout_builder_component_attributes.services.yml
Drupal\layout_builder_component_attributes\EventSubscriber\LayoutBuilderComponentRenderArray

File

src/EventSubscriber/LayoutBuilderComponentRenderArray.php, line 12

Namespace

Drupal\layout_builder_component_attributes\EventSubscriber
View source
class LayoutBuilderComponentRenderArray implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY] = [
      'onBuildRender',
    ];
    return $events;
  }

  /**
   * Adds block classes to section component.
   *
   * @param \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event
   *   The section component render event.
   */
  public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
    $build = $event
      ->getBuild();
    if (!empty($build)) {
      $build['#component_attributes'] = $event
        ->getComponent()
        ->get('component_attributes');
      $event
        ->setBuild($build);
    }
  }

}

Members