當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UrlGeneratorInterface::getContext方法代碼示例

本文整理匯總了PHP中Symfony\Component\Routing\Generator\UrlGeneratorInterface::getContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlGeneratorInterface::getContext方法的具體用法?PHP UrlGeneratorInterface::getContext怎麽用?PHP UrlGeneratorInterface::getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Routing\Generator\UrlGeneratorInterface的用法示例。


在下文中一共展示了UrlGeneratorInterface::getContext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate

 /**
  * @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;
 }
開發者ID:artem-frolov,項目名稱:locale-switcher-bundle,代碼行數:23,代碼來源:Router.php

示例2: prepareRouterContext

 /**
  * 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);
     }
 }
開發者ID:axelvnk,項目名稱:elcodi,代碼行數:16,代碼來源:ImageExtension.php

示例3: getContext

 /**
  * {@inheritdoc}
  */
 public function getContext()
 {
     return $this->wrapped->getContext();
 }
開發者ID:AnimalDesign,項目名稱:bolt-translate,代碼行數:7,代碼來源:LocalizedUrlGenerator.php

示例4: testRequestContext

 /**
  * @depends testUrlGeneratorInterface
  *
  * @param UrlGeneratorInterface $generator
  */
 public function testRequestContext($generator)
 {
     $generator->setContext(new RequestContext('/bolt'));
     $this->assertSame('/bolt', $generator->getContext()->getBaseUrl());
 }
開發者ID:nectd,項目名稱:nectd-web,代碼行數:10,代碼來源:UrlGeneratorFragmentWrapperTest.php

示例5: getContext

 /**
  * {@inheritdoc}
  */
 public function getContext()
 {
     return $this->router->getContext();
 }
開發者ID:contao,項目名稱:core-bundle,代碼行數:7,代碼來源:UrlGenerator.php

示例6: getLocale

 /**
  * Return current locale
  * @return string
  */
 protected function getLocale()
 {
     return $this->generator->getContext()->getParameter('_locale');
 }
開發者ID:pmaxs,項目名稱:silex-locale,代碼行數:8,代碼來源:UrlGenerator.php


注:本文中的Symfony\Component\Routing\Generator\UrlGeneratorInterface::getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。