/** * Sitemap preview index action. * * @param Request $request * * @return Response * * @throws NotFoundHttpException */ public function indexAction(Request $request) { $route = null; if (null !== ($routePattern = $request->get('route', null))) { $route = $this->routeManager->findByRoutePattern($routePattern); } if (null === $route) { throw new NotFoundHttpException(sprintf('Not found route: %s', $routePattern)); } $query = array('_route_params' => array('_route_object' => $route)); $subRequest = $request->duplicate($query, null, $route->getDefaults()); return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); }
/** * Has route. * * @param string $routePattern * @param string $routeName * * @return bool * * @throws RoutingRuntimeException */ private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return null !== $route && $routeName !== $route->getName(); }
/** * {@inheritdoc} */ public function findByRoutePattern($routePattern) { foreach ($this->routes as $route) { if ($routePattern === $route->getRoutePattern()) { return $route; } } return $this->routeManager->findByRoutePattern($routePattern); }
/** * Get route by pattern. * * @param string $pattern * * @return null|RouteInterface */ public function getRouteByPattern($pattern) { return $this->routeManager->findByRoutePattern($pattern); }