You are here

class LayoutBuilderBrowserEventSubscriber in Gin Layout Builder 1.0.x

Class LayoutBuilderBrowserEventSubscriber.

Add layout builder css class layout-builder-browser.

Hierarchy

Expanded class hierarchy of LayoutBuilderBrowserEventSubscriber

1 string reference to 'LayoutBuilderBrowserEventSubscriber'
gin_lb.services.yml in ./gin_lb.services.yml
gin_lb.services.yml
1 service uses LayoutBuilderBrowserEventSubscriber
gin_lb.layout_choose_controller_alter in ./gin_lb.services.yml
Drupal\gin_lb\EventSubscriber\LayoutBuilderBrowserEventSubscriber

File

src/EventSubscriber/LayoutBuilderBrowserEventSubscriber.php, line 14

Namespace

Drupal\gin_lb\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
LayoutBuilderBrowserEventSubscriber::getSubscribedEvents public static function
LayoutBuilderBrowserEventSubscriber::onView public function Add layout-builder-browser class layout_builder.choose_block build block.