class RouteSubscriber extends RouteSubscriberBase (View source)

Builds up the routes of all views.

The general idea is to execute first all alter hooks to determine which routes are overridden by views. This information is used to determine which views have to be added by views in the dynamic event.

Properties

protected array $viewsDisplayPairs

Stores a list of view,display IDs which haven't be used in the alter event.

protected EntityStorageInterface $viewStorage

The view storage.

protected StateInterface $state

The state key value store.

protected array $viewRouteNames

Stores an array of route names keyed by view_id.display_id.

Methods

alterRoutes(RouteCollection $collection)

Alters existing routes for a specific collection.

static 
getSubscribedEvents()

{@inheritdoc}

onAlterRoutes(RouteBuildEvent $event)

Delegates the route altering to self::alterRoutes().

__construct(EntityTypeManagerInterface $entity_type_manager, StateInterface $state)

Constructs a \Drupal\views\EventSubscriber\RouteSubscriber instance.

reset()

Resets the internal state of the route subscriber.

getViewsDisplayIDsWithRoute()

Gets all the views and display IDs using a route.

RouteCollection
routes()

Returns a set of route objects.

routeRebuildFinished()

Stores the new route names after they have been rebuilt.

getApplicableViews()

Returns all views/display combinations with routes.

Details

protected alterRoutes(RouteCollection $collection)

Alters existing routes for a specific collection.

Parameters

RouteCollection $collection

The route collection for adding routes.

static getSubscribedEvents()

{@inheritdoc}

onAlterRoutes(RouteBuildEvent $event)

Delegates the route altering to self::alterRoutes().

Parameters

RouteBuildEvent $event

The route build event.

__construct(EntityTypeManagerInterface $entity_type_manager, StateInterface $state)

Constructs a \Drupal\views\EventSubscriber\RouteSubscriber instance.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager service.

StateInterface $state

The state key value store.

reset()

Resets the internal state of the route subscriber.

protected getViewsDisplayIDsWithRoute()

Gets all the views and display IDs using a route.

RouteCollection routes()

Returns a set of route objects.

Return Value

RouteCollection

A route collection.

routeRebuildFinished()

Stores the new route names after they have been rebuilt.

Callback for the RoutingEvents::FINISHED event.

See also

\Drupal\views\EventSubscriber::getSubscribedEvents()

protected getApplicableViews()

Returns all views/display combinations with routes.