You are here

class RouteSubscriber in Layout Builder Restrictions 8.2

Same name in this branch
  1. 8.2 src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions\Routing\RouteSubscriber
  2. 8.2 modules/layout_builder_restrictions_by_region/src/Routing/RouteSubscriber.php \Drupal\layout_builder_restrictions_by_region\Routing\RouteSubscriber

Override the controller for layout_builder.move_block.

Hierarchy

  • class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
layout_builder_restrictions.services.yml in ./layout_builder_restrictions.services.yml
layout_builder_restrictions.services.yml
1 service uses RouteSubscriber
layout_builder_restrictions.route_subscriber in ./layout_builder_restrictions.services.yml
Drupal\layout_builder_restrictions\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 11

Namespace

Drupal\layout_builder_restrictions\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection
      ->get('layout_builder.move_block')) {
      $defaults = $route
        ->getDefaults();
      $defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\MoveBlockController::build';
      $route
        ->setDefaults($defaults);
    }
    if ($route = $collection
      ->get('layout_builder.move_block_form')) {

      // Provide validation to the Layout Builder MoveBlock form.
      $route
        ->setDefault('_form', '\\Drupal\\layout_builder_restrictions\\Form\\MoveBlockForm');
    }

    // Add inline block filtering to parent class
    // Drupal\layout_builder\Controller\ChooseBlockController.
    if ($route = $collection
      ->get('layout_builder.choose_block')) {
      $defaults = $route
        ->getDefaults();
      $defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\ChooseBlockController::build';
      $route
        ->setDefaults($defaults);
    }
    if ($route = $collection
      ->get('layout_builder.choose_inline_block')) {
      $defaults = $route
        ->getDefaults();
      $defaults['_controller'] = '\\Drupal\\layout_builder_restrictions\\Controller\\ChooseBlockController::inlineBlockList';
      $route
        ->setDefaults($defaults);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes public function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1