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


PHP RouterInterface::getOriginalRouteCollection方法代码示例

本文整理汇总了PHP中Symfony\Component\Routing\RouterInterface::getOriginalRouteCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP RouterInterface::getOriginalRouteCollection方法的具体用法?PHP RouterInterface::getOriginalRouteCollection怎么用?PHP RouterInterface::getOriginalRouteCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Routing\RouterInterface的用法示例。


在下文中一共展示了RouterInterface::getOriginalRouteCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $format = null;
     if (is_string($this->forceFormat)) {
         $format = $this->forceFormat;
     } else {
         $request = $event->getRequest();
         if ($this->router instanceof I18nRouter) {
             $collection = $this->router->getOriginalRouteCollection();
         } else {
             $collection = $this->router->getRouteCollection();
         }
         $route = $collection->get($request->get('_route'));
         if (!empty($route)) {
             $defaultFormat = is_null($route->getDefault('_format')) ? 'html' : $route->getDefault('_format');
         } else {
             $defaultFormat = 'html';
         }
         $format = !is_null($request->attributes->get('_format')) ? $request->attributes->get('_format') : $defaultFormat;
     }
     if (!is_null($format)) {
         $serviceName = 'vsymfo_core.service.' . strtolower($format) . '_document';
         if ($this->container->has($serviceName) && $this->container->get($serviceName) instanceof DocumentFactoryInterface) {
             $service = $this->container->get($serviceName);
         } else {
             $service = $this->container->get('vsymfo_core.service.txt_document');
         }
         $doc = $service->createDocument();
         $this->container->get('vsymfo_core.service.document')->setDefaultsToDocument($doc);
         $this->container->set($this->serviceName, $doc);
     }
 }
开发者ID:mikoweb,项目名称:vsymfo-core-bundle,代码行数:35,代码来源:DocumentListener.php

示例2: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($this->router instanceof I18nRouter) {
         $collection = $this->router->getOriginalRouteCollection();
     } else {
         $collection = $this->router->getRouteCollection();
     }
     $route = $collection->get($request->get('_route'));
     if (!empty($route) && $route->hasOption('theme_group')) {
         $group = $route->getOption('theme_group');
         $this->theme->setName($group . '_' . $this->container->getParameter('vsymfo_core.theme_' . $group));
     }
 }
开发者ID:mikoweb,项目名称:vsymfo-core-bundle,代码行数:17,代码来源:ThemeGroupListener.php

示例3: addRouteParameters

 /**
  * @param string $route
  * @param \SimpleXMLElement $params
  * @param boolean $hidden
  * @param array $options
  */
 protected function addRouteParameters($route, \SimpleXMLElement $params, $hidden, array &$options)
 {
     $options['routeParameters'] = [];
     $parameters = $params->xpath('param');
     if (!empty($parameters)) {
         foreach ($parameters as $param) {
             if (isset($param['name'])) {
                 $options['routeParameters'][(string) $param['name']] = (string) $param;
             }
         }
     }
     if ($hidden) {
         if ($this->router instanceof I18nRouter) {
             $collection = $this->router->getOriginalRouteCollection();
         } else {
             $collection = $this->router->getRouteCollection();
         }
         $route = $collection->get($route);
         $variables = [];
         preg_match_all('#\\{\\w+\\}#', $route->getPath(), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             $variables[] = substr($match[0][0], 1, -1);
         }
         if (!empty($variables)) {
             $defaults = $route->getDefaults();
             foreach ($variables as $variable) {
                 if (!isset($options['routeParameters'][$variable]) && !isset($defaults[$variable])) {
                     $value = $this->request->getCurrentRequest()->attributes->get($variable, '0');
                     $options['routeParameters'][$variable] = empty($value) ? '0' : $value;
                 }
             }
         }
     }
 }
开发者ID:mikoweb,项目名称:vsymfo-core,代码行数:40,代码来源:MenuBuilderAbstract.php


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