You are here

class RouteSubscriber in Layout Builder Browser 8

Listens to the dynamic route events.

Hierarchy

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

Expanded class hierarchy of RouteSubscriber

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

File

src/Routing/RouteSubscriber.php, line 12

Namespace

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

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Override the layout builder choose block controller with ours.
    if ($route = $collection
      ->get('layout_builder.choose_block')) {
      $route
        ->setDefault('_controller', '\\Drupal\\layout_builder_browser\\Controller\\BrowserController::browse');
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {

    // Ensure we alter the controller after other modules, see
    // https://www.drupal.org/node/3129158.
    $events[RoutingEvents::ALTER] = [
      'onAlterRoutes',
      -110,
    ];
    return $events;
  }

}

Members

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