当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::getContext方法代码示例

本文整理汇总了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()
     }
 }
开发者ID:ciaranmcnulty,项目名称:symfony-prefix-route-example,代码行数:8,代码来源:Listener.php

示例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;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:14,代码来源:PortalURLExtension.php

示例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);
     }
 }
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:14,代码来源:PortalURLExtension.php

示例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;
 }
开发者ID:yceruto,项目名称:breadcrumbs-bundle,代码行数:21,代码来源:BreadcrumbsBuilder.php

示例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;
 }
开发者ID:rodgermd,项目名称:sofort2-bundle,代码行数:14,代码来源:SofortRoutesManager.php

示例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();
 }
开发者ID:wucdbm,项目名称:menu-builder-bundle,代码行数:20,代码来源:MenuItemExtension.php

示例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;
 }
开发者ID:risinglf,项目名称:UniversiBO,代码行数:22,代码来源:FeedGenerator.php

示例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;
 }
开发者ID:TeodorSolvic,项目名称:EntitySerializationExample,代码行数:10,代码来源:ImageSerializationHelper.php

示例9: getApiVersion

 /**
  * return string
  */
 protected function getApiVersion()
 {
     return $this->router->getContext()->getApiVersion();
 }
开发者ID:eliberty,项目名称:api-bundle,代码行数:7,代码来源:BaseHandler.php


注:本文中的Symfony\Bundle\FrameworkBundle\Routing\Router::getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。