RouteSubscriber::routes

public 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\EventSubscriber

Code

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;
}
doc_Drupal
2016-10-29 09:39:28
Comments
Leave a Comment

Please login to continue.