class LayoutBuilderBrowserEventSubscriber in Gin Layout Builder 1.0.x
Class LayoutBuilderBrowserEventSubscriber.
Add layout builder css class layout-builder-browser.
Hierarchy
- class \Drupal\gin_lb\EventSubscriber\LayoutBuilderBrowserEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of LayoutBuilderBrowserEventSubscriber
1 string reference to 'LayoutBuilderBrowserEventSubscriber'
1 service uses LayoutBuilderBrowserEventSubscriber
File
- src/
EventSubscriber/ LayoutBuilderBrowserEventSubscriber.php, line 14
Namespace
Drupal\gin_lb\EventSubscriberView source
class LayoutBuilderBrowserEventSubscriber implements EventSubscriberInterface {
/**
* Add layout-builder-browser class layout_builder.choose_block build block.
*/
public function onView(GetResponseForControllerResultEvent $event) {
$request = $event
->getRequest();
$route = $request->attributes
->get('_route');
if ($route == 'layout_builder.choose_block') {
$build = $event
->getControllerResult();
if (is_array($build) && !isset($build['add_block'])) {
$build['block_categories']['#attributes']['class'][] = 'layout-builder-browser';
$event
->setControllerResult($build);
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::VIEW][] = [
'onView',
50,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LayoutBuilderBrowserEventSubscriber:: |
public static | function | ||
LayoutBuilderBrowserEventSubscriber:: |
public | function | Add layout-builder-browser class layout_builder.choose_block build block. |