You are here

public function LayoutBuilderRestrictionsSubscriber::onKernelView in Layout Builder Restrictions 8

Subscriber for kernel view.

File

src/EventSubscriber/LayoutBuilderRestrictionsSubscriber.php, line 42

Class

LayoutBuilderRestrictionsSubscriber
Layout builder restrictions event subscriber.

Namespace

Drupal\layout_builder_restrictions\EventSubscriber

Code

public function onKernelView(GetResponseForControllerResultEvent $event) {
  $route_name = $this->routeMatch
    ->getCurrentRouteMatch()
    ->getRouteName();
  $result = $event
    ->getControllerResult();
  switch ($route_name) {
    case 'layout_builder.choose_section':
      $this
        ->alterLayoutChooser($result);
      break;
    case 'layout_builder.choose_block':
      $this
        ->alterBlockChooser($result);
      break;
    default:
      return;
  }
  $event
    ->setControllerResult($result);
}