get('view.airports.page_1')) { $route->setDefault('taxonomy_vocabulary', 'airports'); } } /** * Adds variables to the current route match object if it is the airport view. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The response event, which contains the current request. */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); // Deliberately avoid calling \Drupal::routeMatch()->getRouteName() because // that will instantiate a protected route match object that will not have // the raw variable we want to add. if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) === 'view.airports.page_1') { if ($raw = $request->attributes->get('_raw_variables', array())) { $raw->add(array('taxonomy_vocabulary' => 'airports')); $request->attributes->set('_raw_variables', $raw); } } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events = parent::getSubscribedEvents(); // The route object attribute will have been set in // router_listener::onKernelRequest(), which has a priority of 32. $events[KernelEvents::REQUEST][] = array('onKernelRequest', 31); return $events; } }