/** * @param string $name * @param array $parameters * @param bool $referenceType * * @return string * * @see UrlGeneratorInterface::generate */ public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { $currentLocale = $this->router->getContext()->getParameter('_locale'); if (isset($parameters['_locale'])) { $targetLocale = $parameters['_locale']; unset($parameters['_locale']); } else { $targetLocale = $currentLocale; } $this->router->getContext()->setParameter('_locale', $targetLocale); $result = $this->router->generate($this->getCustomRouteName($name, $currentLocale, $targetLocale), $parameters, $referenceType); $this->router->getContext()->setParameter('_locale', $currentLocale); return $result; }
/** * Prepares the Host part of a image resize URL * * @return mixed Route reference type */ private function prepareRouterContext() { if ($this->generatedRouteHost) { $this->router->setContext($this->modifiedContext); /** * When a Host is set for the image route, * we need to change the route context URL */ $this->router->getContext()->setHost($this->generatedRouteHost); } }
/** * {@inheritdoc} */ public function getContext() { return $this->wrapped->getContext(); }
/** * @depends testUrlGeneratorInterface * * @param UrlGeneratorInterface $generator */ public function testRequestContext($generator) { $generator->setContext(new RequestContext('/bolt')); $this->assertSame('/bolt', $generator->getContext()->getBaseUrl()); }
/** * {@inheritdoc} */ public function getContext() { return $this->router->getContext(); }
/** * Return current locale * @return string */ protected function getLocale() { return $this->generator->getContext()->getParameter('_locale'); }