LayoutBuilderComponentRenderArray.php in Layout Builder Component Attributes 1.1.x
Same filename and directory in other branches
File
src/EventSubscriber/LayoutBuilderComponentRenderArray.phpView source
<?php
namespace Drupal\layout_builder_component_attributes\EventSubscriber;
use Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent;
use Drupal\layout_builder\LayoutBuilderEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class LayoutBuilderComponentRenderArray.
*/
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);
}
}
}
Classes
Name | Description |
---|---|
LayoutBuilderComponentRenderArray | Class LayoutBuilderComponentRenderArray. |