public function onKernelRequest(GetResponseEvent $event) { if ($id = $event->getRequest()->attributes->get('customer_id')) { $this->router->getContext()->setParameter('customer_id', $id); } else { // maybe redirect by passing a RedirectResponse to $event->setResponse() } }
/** * @return RequestContext */ private function updateRequestContext() { $url = $this->config->get('oro_ui.application_url'); if (empty($url)) { throw new \RuntimeException('No Application URL configured, unable to generate links'); } $context = $this->router->getContext(); $origContext = clone $context; $this->setUrlInContext($url, $context); return $origContext; }
private function updateRequestContext() { $url = $this->config->get('oro_ui.application_url'); if (empty($url)) { throw new \RuntimeException('No Application URL configured, unable to generate links'); } list($scheme, $host, $baseUrl) = $this->getUrlParts($url); $context = $this->router->getContext(); $context->setScheme($scheme); $context->setHost($host); if (!empty($baseUrl)) { $context->setBaseUrl($baseUrl); } }
/** * Create a breadcrumb through current request path * * @return Breadcrumbs */ public function createFromRequest() { if (empty($this->matcher)) { $this->matcher = new TraceableUrlMatcher($this->router->getRouteCollection(), $this->router->getContext()); } $breadcrumbs = new Breadcrumbs(); $parent = null; $paths = $this->getBreadcrumbsPaths(); foreach ($paths as $path) { if ($node = $this->createBreadcrumbsNode($path, $parent)) { $breadcrumbs->addNode($node); $parent = $path; } } return $breadcrumbs; }
/** * Updates url * * @param $url * * @return string */ protected function updateUrl($url) { if ($this->defaultHost) { $url = str_replace($this->router->getContext()->getHost(), $this->defaultHost, $url); } return $url; }
protected function getValue(MenuItemParameter $parameter) { if ($parameter->getUseValueFromContext()) { $routeParameter = $parameter->getParameter(); // If the current context has this parameter, use it if ($this->router->getContext()->hasParameter($routeParameter->getParameter())) { return $this->router->getContext()->getParameter($routeParameter->getParameter()); } // Otherwise, use the default value for this route // Note: This might change, and upon importing routes anew // The URLs generated will now use the new default value $default = $routeParameter->getDefaultValue(); if ($default) { return $default; } } // If no value was found in the context or the default route parameter value // return the last copy of its default return $parameter->getValue(); }
/** * Generates a feed from Canale * @param Canale $canale * @return Feed */ public function generateFeed(Canale $canale, Router $router, $legacy = true) { $context = $router->getContext(); $base = $context->getScheme() . '://' . $context->getHost() . '/v2.php?do=ShowPermalink&id_notizia='; $idCanale = $canale->getIdCanale(); $feed = new Feed(); $feed->setTitle($nome = $canale->getTitolo()); $feed->setDescription('Feed ' . $nome); $feed->setLink($router->generate('rss', array('idCanale' => $idCanale), true)); $newsRepository = $this->repository; $news = $newsRepository->findByCanale($idCanale, 20); $news = is_array($news) ? $news : array(); foreach ($news as $item) { $this->newsToEntry($feed, $item, $base, $router, $legacy); } return $feed; }
/** * @param string $publicUrl * @return string */ private function generateFullPublicUrl($publicUrl) { $scheme = $this->router->getContext()->getScheme() . '://'; $host = $this->router->getContext()->getHost(); return $scheme . $host . $publicUrl; }
/** * return string */ protected function getApiVersion() { return $this->router->getContext()->getApiVersion(); }