function RouteSubscriber::buildRoutes
Same name and namespace in other branches
- main core/modules/views/src/EventSubscriber/RouteSubscriber.php \Drupal\views\EventSubscriber\RouteSubscriber::buildRoutes()
Provides new routes during the RoutingEvents::STATIC phase.
This is the object-oriented equivalent of a 'route_callbacks' entry in a *.routing.yml file.
Return value
\Symfony\Component\Routing\RouteCollection A collection of new routes to add.
Overrides RouteSubscriberBase::buildRoutes
1 call to RouteSubscriber::buildRoutes()
- RouteSubscriber::routes in core/
modules/ views/ src/ EventSubscriber/ RouteSubscriber.php - Returns a set of route objects.
File
-
core/
modules/ views/ src/ EventSubscriber/ RouteSubscriber.php, line 108
Class
- RouteSubscriber
- Builds up the routes of all views.
Namespace
Drupal\views\EventSubscriberCode
protected function buildRoutes() : RouteCollection {
$collection = new RouteCollection();
foreach ($this->getViewsDisplayIDsWithRoute() as $pair) {
[$view_id, $display_id] = explode('.', $pair);
$view = $this->viewStorage
->load($view_id);
// @todo This should have an executable factory injected.
if (($view = $view->getExecutable()) && $view instanceof ViewExecutable) {
if ($view->setDisplay($display_id) && $display = $view->displayHandlers
->get($display_id)) {
if ($display instanceof DisplayRouterInterface) {
$this->viewRouteNames += (array) $display->collectRoutes($collection);
}
}
$view->destroy();
}
}
$this->state
->set('views.view_route_names', $this->viewRouteNames);
return $collection;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.