当前位置: 首页>>代码示例>>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;未经允许,请勿转载。