本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Routing\Router::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getContext方法的具体用法?PHP Router::getContext怎么用?PHP Router::getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Routing\Router
的用法示例。
在下文中一共展示了Router::getContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onKernelRequest
public function onKernelRequest(GetResponseEvent $event)
{
if ($id = $event->getRequest()->attributes->get('customer_id')) {
$this->router->getContext()->setParameter('customer_id', $id);
} else {
// maybe redirect by passing a RedirectResponse to $event->setResponse()
}
}
示例2: updateRequestContext
/**
* @return RequestContext
*/
private function updateRequestContext()
{
$url = $this->config->get('oro_ui.application_url');
if (empty($url)) {
throw new \RuntimeException('No Application URL configured, unable to generate links');
}
$context = $this->router->getContext();
$origContext = clone $context;
$this->setUrlInContext($url, $context);
return $origContext;
}
示例3: updateRequestContext
private function updateRequestContext()
{
$url = $this->config->get('oro_ui.application_url');
if (empty($url)) {
throw new \RuntimeException('No Application URL configured, unable to generate links');
}
list($scheme, $host, $baseUrl) = $this->getUrlParts($url);
$context = $this->router->getContext();
$context->setScheme($scheme);
$context->setHost($host);
if (!empty($baseUrl)) {
$context->setBaseUrl($baseUrl);
}
}
示例4: createFromRequest
/**
* Create a breadcrumb through current request path
*
* @return Breadcrumbs
*/
public function createFromRequest()
{
if (empty($this->matcher)) {
$this->matcher = new TraceableUrlMatcher($this->router->getRouteCollection(), $this->router->getContext());
}
$breadcrumbs = new Breadcrumbs();
$parent = null;
$paths = $this->getBreadcrumbsPaths();
foreach ($paths as $path) {
if ($node = $this->createBreadcrumbsNode($path, $parent)) {
$breadcrumbs->addNode($node);
$parent = $path;
}
}
return $breadcrumbs;
}
示例5: updateUrl
/**
* Updates url
*
* @param $url
*
* @return string
*/
protected function updateUrl($url)
{
if ($this->defaultHost) {
$url = str_replace($this->router->getContext()->getHost(), $this->defaultHost, $url);
}
return $url;
}
示例6: getValue
protected function getValue(MenuItemParameter $parameter)
{
if ($parameter->getUseValueFromContext()) {
$routeParameter = $parameter->getParameter();
// If the current context has this parameter, use it
if ($this->router->getContext()->hasParameter($routeParameter->getParameter())) {
return $this->router->getContext()->getParameter($routeParameter->getParameter());
}
// Otherwise, use the default value for this route
// Note: This might change, and upon importing routes anew
// The URLs generated will now use the new default value
$default = $routeParameter->getDefaultValue();
if ($default) {
return $default;
}
}
// If no value was found in the context or the default route parameter value
// return the last copy of its default
return $parameter->getValue();
}
示例7: generateFeed
/**
* Generates a feed from Canale
* @param Canale $canale
* @return Feed
*/
public function generateFeed(Canale $canale, Router $router, $legacy = true)
{
$context = $router->getContext();
$base = $context->getScheme() . '://' . $context->getHost() . '/v2.php?do=ShowPermalink&id_notizia=';
$idCanale = $canale->getIdCanale();
$feed = new Feed();
$feed->setTitle($nome = $canale->getTitolo());
$feed->setDescription('Feed ' . $nome);
$feed->setLink($router->generate('rss', array('idCanale' => $idCanale), true));
$newsRepository = $this->repository;
$news = $newsRepository->findByCanale($idCanale, 20);
$news = is_array($news) ? $news : array();
foreach ($news as $item) {
$this->newsToEntry($feed, $item, $base, $router, $legacy);
}
return $feed;
}
示例8: generateFullPublicUrl
/**
* @param string $publicUrl
* @return string
*/
private function generateFullPublicUrl($publicUrl)
{
$scheme = $this->router->getContext()->getScheme() . '://';
$host = $this->router->getContext()->getHost();
return $scheme . $host . $publicUrl;
}
示例9: getApiVersion
/**
* return string
*/
protected function getApiVersion()
{
return $this->router->getContext()->getApiVersion();
}