コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
ファイル: ImageExtension.php プロジェクト: axelvnk/elcodi
 /**
  * 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);
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function getContext()
 {
     return $this->wrapped->getContext();
 }
コード例 #4
0
 /**
  * @depends testUrlGeneratorInterface
  *
  * @param UrlGeneratorInterface $generator
  */
 public function testRequestContext($generator)
 {
     $generator->setContext(new RequestContext('/bolt'));
     $this->assertSame('/bolt', $generator->getContext()->getBaseUrl());
 }
コード例 #5
0
ファイル: UrlGenerator.php プロジェクト: contao/core-bundle
 /**
  * {@inheritdoc}
  */
 public function getContext()
 {
     return $this->router->getContext();
 }
コード例 #6
0
ファイル: UrlGenerator.php プロジェクト: pmaxs/silex-locale
 /**
  * Return current locale
  * @return string
  */
 protected function getLocale()
 {
     return $this->generator->getContext()->getParameter('_locale');
 }