當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。