function RouteSubscriber::routes
Same name in other branches
- 9 core/modules/views/src/EventSubscriber/RouteSubscriber.php \Drupal\views\EventSubscriber\RouteSubscriber::routes()
- 10 core/modules/views/src/EventSubscriber/RouteSubscriber.php \Drupal\views\EventSubscriber\RouteSubscriber::routes()
- 11.x core/modules/views/src/EventSubscriber/RouteSubscriber.php \Drupal\views\EventSubscriber\RouteSubscriber::routes()
Returns a set of route objects.
Return value
\Symfony\Component\Routing\RouteCollection A route collection.
File
-
core/
modules/ views/ src/ EventSubscriber/ RouteSubscriber.php, line 111
Class
- RouteSubscriber
- Builds up the routes of all views.
Namespace
Drupal\views\EventSubscriberCode
public function routes() {
$collection = new RouteCollection();
foreach ($this->getViewsDisplayIDsWithRoute() as $pair) {
list($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.