本文整理汇总了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;
}
示例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);
}
}
示例3: getContext
/**
* {@inheritdoc}
*/
public function getContext()
{
return $this->wrapped->getContext();
}
示例4: testRequestContext
/**
* @depends testUrlGeneratorInterface
*
* @param UrlGeneratorInterface $generator
*/
public function testRequestContext($generator)
{
$generator->setContext(new RequestContext('/bolt'));
$this->assertSame('/bolt', $generator->getContext()->getBaseUrl());
}
示例5: getContext
/**
* {@inheritdoc}
*/
public function getContext()
{
return $this->router->getContext();
}
示例6: getLocale
/**
* Return current locale
* @return string
*/
protected function getLocale()
{
return $this->generator->getContext()->getParameter('_locale');
}