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


PHP Router::getRouteCollection方法代码示例

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


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

示例1: __construct

 /**
  * @param Router $router
  * @param $badges
  * @param string $packagist_route
  */
 public function __construct(Router $router, array $badges, array $allInBadges, $packagist_route = 'pugx_badge_packagist')
 {
     $this->router = $router;
     $this->badges = $badges;
     $this->allInBadges = $allInBadges;
     $this->packagistRoute = $packagist_route;
     $this->routes = $this->router->getRouteCollection();
 }
开发者ID:kartik-v,项目名称:badge-poser,代码行数:13,代码来源:SnippetGenerator.php

示例2: __construct

 /**
  * SiteMapService constructor.
  *
  * @param EntityManager $em
  * @param Router $router
  */
 public function __construct(EntityManager $em, $router)
 {
     $this->em = $em;
     $this->router = $router;
     $this->routes = $this->router->getRouteCollection()->all();
     $this->siteMapOptionService = new SiteMapOptionService();
     $this->siteMapControllerService = new SiteMapControllerService($em, $router);
 }
开发者ID:botalaszlo,项目名称:symfony-repositemap-bundle,代码行数:14,代码来源:SiteMapService.php

示例3: getPreprocessorWriterResponse

 public function getPreprocessorWriterResponse($preprocessorRouteName, array $attributes, Request $currentRequest)
 {
     // For localhost, the way is the same as for public to private forward.
     $attributes['_controller'] = $this->router->getRouteCollection()->get($preprocessorRouteName)->getDefault('_controller');
     $subRequest = $currentRequest->duplicate(null, null, $attributes);
     $response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     /* @var $response \Symfony\Component\HttpFoundation\Response */
     $response->setStatusCode($response->getStatusCode(), $response->headers->get('ps_status_text', null));
     return $response;
 }
开发者ID:xGouley,项目名称:PSPublicWriterBundle,代码行数:10,代码来源:LocalhostForwarder.php

示例4: getRoutesByBundleDir

 /**
  * Get routes by bundle dir
  *
  * @param string $dir
  *
  * @return array|Router
  */
 public function getRoutesByBundleDir($dir)
 {
     $routes = $this->router->getRouteCollection()->all();
     $resultRoutes = array();
     /** @var \Symfony\Component\Routing\Route $route */
     foreach ($routes as $name => $route) {
         if ($this->getBundleNameFromString($dir) == $this->getBundleNameFromString($route->getDefault('_controller'))) {
             $resultRoutes[] = $name;
         }
     }
     return $resultRoutes;
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:TranslationExtractor.php

示例5: loadRoutes

 public function loadRoutes($path, $options = array())
 {
     $filelocator = new FileLocator($path);
     $routeloader = new YamlFileLoader($filelocator);
     $router = new Router($routeloader, $path, $options);
     $matcher = $router->getMatcher();
     $routeCollection = $router->getRouteCollection();
     $context = $router->getContext();
     $this->dispatcher->addSubscriber(new HttpKernel\EventListener\RouterListener($matcher));
     $this->shared['url.generator'] = new UrlGenerator($routeCollection, $context);
     $this->router = $router;
     return $router->getRouteCollection();
 }
开发者ID:ubick,项目名称:glue,代码行数:13,代码来源:Application.php

示例6: getRoutes

 /**
  * Returns the list of routes that should be rendered.
  *
  * @return Symfony\Component\Routing\Route[] List of routes that should be rendered.
  */
 protected function getRoutes()
 {
     if (0 === count($this->routes)) {
         return $this->router->getRouteCollection()->all();
     }
     $routes = [];
     foreach ($this->routes as $name) {
         $route = $this->router->getRouteCollection()->get($name);
         if (null !== $route) {
             $routes[$name] = $route;
         }
     }
     return $routes;
 }
开发者ID:braincrafted,项目名称:static-site-bundle,代码行数:19,代码来源:RoutesRenderer.php

示例7: getRoutes

 /**
  * Getting routes
  *
  * @return ArrayCollection
  */
 private function getRoutes()
 {
     $routeCollection = $this->router->getRouteCollection();
     $routes = new ArrayCollection();
     foreach ($routeCollection as $name => $route) {
         if ($route instanceof Route) {
             $options = $route->getOptions();
             if (isset($options['expose']) && $options['expose'] === true) {
                 $methods = $route->getMethods();
                 $routes->set($name, array('method' => reset($methods), 'pattern' => $route->getPath()));
             }
         }
     }
     return $routes;
 }
开发者ID:RomanShumkov,项目名称:EcentriaRestBundle,代码行数:20,代码来源:ConfigurationManager.php

示例8: __construct

 public function __construct(Router $router, ContainerInterface $container)
 {
     $this->routeCollection = $router->getRouteCollection();
     $this->translator = $container->get('translator');
     $this->translationDomain = $container->getParameter('symfonian_id.admin.translation_domain');
     $this->authorizationChecker = $container->get('security.authorization_checker');
 }
开发者ID:deryfebriantara,项目名称:AdminBundle,代码行数:7,代码来源:Builder.php

示例9: register

 /**
  * {@inheritdoc}
  */
 public function register(Container $app)
 {
     /**
      * Holds information about the current request
      *
      * @return RequestContext
      */
     $app['request_context'] = function () use($app) {
         $context = new RequestContext();
         // set default http & https ports if not set
         $context->setHttpPort(isset($app['request.http_port']) ? $app['request.http_port'] : 80);
         $context->setHttpsPort(isset($app['request.https_port']) ? $app['request.https_port'] : 443);
         return $context;
     };
     /**
      * Matches URL based on a set of routes.
      *
      * @return UrlMatcher
      */
     $app['matcher'] = function () use($app) {
         return new UrlMatcher($app['router'], $app['request_context']);
     };
     /**
      * Router
      */
     $options = array('cache_dir' => true === $app['use_cache'] ? __DIR__ . '/' . self::CACHE_DIRECTORY : null, 'debug' => true);
     $app['router'] = function () use($app, $options) {
         $router = new Router($app['config.loader'], sprintf(self::CONFIG_ROUTES_FILE, $app['env']), $options);
         return $router->getRouteCollection();
     };
 }
开发者ID:nkstamina,项目名称:framework,代码行数:34,代码来源:RoutingServiceProvider.php

示例10: getRouteCollection

 public function getRouteCollection()
 {
     $collection = parent::getRouteCollection();
     if (null !== $this->appendCollection) {
         $collection->addCollection($this->appendCollection);
         $this->appendCollection = null;
     }
     return $collection;
 }
开发者ID:brodaproject,项目名称:broda,代码行数:9,代码来源:Router.php

示例11: getRoutesByBasename

 /**
  * Based on $baseName, this function returns all routes that match this basename..
  * So if you pass graviton.cont.action; it will return all route names that start with the same.
  * In our routing naming schema, this means all the routes from the same controller.
  *
  * @param string $baseName basename
  *
  * @return array array with matching routes
  */
 public function getRoutesByBasename($baseName)
 {
     $ret = array();
     foreach ($this->router->getRouteCollection()->all() as $routeName => $route) {
         if (preg_match('/^' . $baseName . '/', $routeName)) {
             $ret[$routeName] = $route;
         }
     }
     return $ret;
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:19,代码来源:RestUtils.php

示例12: getRoute

 /**
  * Returns the route that matches the given controller name.
  *
  * @param string $controller Name of the controller
  *
  * @return Route
  */
 protected function getRoute($controller)
 {
     $routes = $this->router->getRouteCollection()->all();
     foreach ($routes as $name => $route) {
         if ($controller === $route->getDefault('_controller')) {
             return [$name, $route];
         }
     }
     return null;
 }
开发者ID:braincrafted,项目名称:static-site-bundle,代码行数:17,代码来源:ControllerRenderer.php

示例13: getLegacyOptions

 /**
  * Try to get controller & parameters with mapping options.
  *
  * If failed to find options, then return the input values.
  *
  * @param string $routeName
  * @param string[] $parameters The route parameters to convert
  * @return array[] An array with: the legacy controller name, then the parameters array
  */
 public final function getLegacyOptions($routeName, $parameters = array())
 {
     $legacyController = $routeName;
     $legacyParameters = $parameters;
     $route = $this->router->getRouteCollection()->get($routeName);
     if ($route) {
         if ($route->hasDefault('_legacy_controller')) {
             $legacyController = $route->getDefault('_legacy_controller');
             if ($route->hasDefault('_legacy_param_mapper_class') && $route->hasDefault('_legacy_param_mapper_method')) {
                 $class = $route->getDefault('_legacy_param_mapper_class');
                 $method = $route->getDefault('_legacy_param_mapper_method');
                 $method = (new \ReflectionClass('\\' . $class))->getMethod($method);
                 $legacyParameters = $method->invoke($method->isStatic() ? null : $method->getDeclaringClass()->newInstance(), $parameters);
             }
         }
     }
     return array($legacyController, $legacyParameters);
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:27,代码来源:UrlGenerator.php

示例14: createPageFromRoute

 /**
  * Creates a Node object based on given $routeName or current route.
  *
  * @param string|null $routeName
  *
  * @return Node
  */
 public function createPageFromRoute($routeName = null)
 {
     if (!$routeName) {
         $routeName = $this->pageStack->getRequest()->attributes->get('_route');
         if (!$routeName) {
             throw new \RuntimeException('Could not detect route name');
         }
     }
     $reflection = new \ReflectionClass($this->router->getGenerator());
     $key = 'jarves_routes';
     $cache = $this->cacher->getFastCache($key);
     $validCache = false;
     $routes = [];
     if ($cache) {
         $validCache = $cache['time'] === filemtime($reflection->getFileName()) && isset($cache['routes']) && is_string($cache['routes']);
         if ($validCache) {
             $routes = unserialize($cache['routes']);
         }
     }
     if (!$validCache) {
         $routes = $this->router->getRouteCollection()->all();
         $this->cacher->setFastCache($key, ['time' => filemtime($reflection->getFileName()), 'routes' => serialize($routes)]);
     }
     if (!isset($routes[$routeName])) {
         throw new \RuntimeException("Route with name `{$routeName}` does not exist");
     }
     $route = $routes[$routeName];
     $url = $this->router->generate($routeName, $this->pageStack->getRequest()->attributes->all());
     $page = Node::createPage($route->getOption('title'), parse_url($url)['path'], $route->getOption('theme'), $route->getOption('layout'));
     if ($route->getOption('meta')) {
         foreach ((array) $route->getOption('meta') as $key => $value) {
             $page->meta->set($key, $value);
         }
     }
     return $page;
 }
开发者ID:jarves,项目名称:jarves,代码行数:43,代码来源:PageResponseFactory.php

示例15: importRouter

 /**
  * @param Router $router
  */
 public function importRouter(Router $router)
 {
     $routes = $this->findAll();
     $toRemove = [];
     /** @var Route $route */
     foreach ($routes as $route) {
         $toRemove[$route->getRoute()] = $route;
     }
     /** @var $collection RouteCollection */
     $collection = $router->getRouteCollection();
     $allRoutes = $collection->all();
     /**
      * @var string $routeName
      * @var SymfonyRoute $route
      */
     foreach ($allRoutes as $routeName => $route) {
         $this->importRoute($routeName, $route);
         unset($toRemove[$routeName]);
     }
     /**
      * @var string $routeName
      * @var Route $route
      */
     foreach ($toRemove as $routeName => $route) {
         /** @var MenuItem $item */
         foreach ($route->getItems() as $item) {
             $parent = $item->getParent();
             /** @var MenuItem $child */
             foreach ($item->getChildren() as $child) {
                 $child->setParent($parent);
                 $this->menuItemRepo->save($child);
             }
         }
         $this->removeRoute($route);
     }
 }
开发者ID:wucdbm,项目名称:menu-builder-bundle,代码行数:39,代码来源:RouteManager.php


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