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


PHP RouteCollection::addCollection方法代码示例

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


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

示例1: load

 /**
  * @param mixed $resource
  * @param null $type
  * @return \Symfony\Component\Routing\RouteCollection
  * @throws \RuntimeException
  */
 public function load($resource, $type = null)
 {
     $routes = new RouteCollection();
     /*
      * For each core bunle then for each module
      */
     // CoreBundle
     $loader = $this->resolver->resolve('@EtuCoreBundle/Api/Resource/', 'annotation');
     if ($loader) {
         $routes->addCollection($loader->load('@EtuCoreBundle/Api/Resource/', 'annotation'));
     }
     // UserBundle
     $loader = $this->resolver->resolve('@EtuUserBundle/Api/Resource/', 'annotation');
     if ($loader) {
         $routes->addCollection($loader->load('@EtuUserBundle/Api/Resource/', 'annotation'));
     }
     /** @var $module Module */
     foreach ($this->kernel->getModulesDefinitions() as $module) {
         $routing = $module->getApiRouting();
         $loader = $this->resolver->resolve($routing['resource'], $routing['type']);
         if ($loader) {
             $routes->addCollection($loader->load($routing['resource'], $routing['type']));
         }
     }
     return $routes;
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:32,代码来源:ApiResourcesRoutingLoader.php

示例2: addRoutes

 /**
  * {@inheritdoc}
  */
 public function addRoutes(RouteCollection $routes)
 {
     if (empty($this->routes)) {
         $this->routes = $routes;
     } else {
         $this->routes->addCollection($routes);
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:MatcherDumper.php

示例3: find

 /**
  * Find a list of controllers
  *
  * @param string $base_path Base path to prepend to file paths
  * @return provider
  */
 public function find($base_path = '')
 {
     $this->routes = new RouteCollection();
     foreach ($this->routing_files as $file_path) {
         $loader = new YamlFileLoader(new FileLocator(phpbb_realpath($base_path)));
         $this->routes->addCollection($loader->load($file_path));
     }
     return $this;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:15,代码来源:provider.php

示例4: testDump

 public function testDump()
 {
     $collection = new RouteCollection();
     // defaults and requirements
     $collection->add('foo', new Route('/foo/{bar}', array('def' => 'test'), array('bar' => 'baz|symfony')));
     // method requirement
     $collection->add('bar', new Route('/bar/{foo}', array(), array('_method' => 'GET|head')));
     // GET method requirement automatically adds HEAD as valid
     $collection->add('barhead', new Route('/barhead/{foo}', array(), array('_method' => 'GET')));
     // simple
     $collection->add('baz', new Route('/test/baz'));
     // simple with extension
     $collection->add('baz2', new Route('/test/baz.html'));
     // trailing slash
     $collection->add('baz3', new Route('/test/baz3/'));
     // trailing slash with variable
     $collection->add('baz4', new Route('/test/{foo}/'));
     // trailing slash and method
     $collection->add('baz5', new Route('/test/{foo}/', array(), array('_method' => 'post')));
     // complex name
     $collection->add('baz.baz6', new Route('/test/{foo}/', array(), array('_method' => 'put')));
     // defaults without variable
     $collection->add('foofoo', new Route('/foofoo', array('def' => 'test')));
     // pattern with quotes
     $collection->add('quoter', new Route('/{quoter}', array(), array('quoter' => '[\']+')));
     // prefixes
     $collection1 = new RouteCollection();
     $collection1->add('foo', new Route('/{foo}'));
     $collection1->add('bar', new Route('/{bar}'));
     $collection2 = new RouteCollection();
     $collection2->addCollection($collection1, '/b\'b');
     $collection1 = new RouteCollection();
     $collection1->add('foo1', new Route('/{foo1}'));
     $collection1->add('bar1', new Route('/{bar1}'));
     $collection2->addCollection($collection1, '/b\'b');
     $collection->addCollection($collection2, '/a');
     // "dynamic" prefix
     $collection1 = new RouteCollection();
     $collection1->add('foo', new Route('/{foo}'));
     $collection1->add('bar', new Route('/{bar}'));
     $collection2 = new RouteCollection();
     $collection2->addCollection($collection1, '/b');
     $collection->addCollection($collection2, '/{_locale}');
     $collection->add('ababa', new Route('/ababa'));
     // some more prefixes
     $collection1 = new RouteCollection();
     $collection1->add('foo', new Route('/{foo}'));
     $collection->addCollection($collection1, '/aba');
     $dumper = new PhpMatcherDumper($collection, new RequestContext());
     $this->assertStringEqualsFile(__DIR__ . '/../../Fixtures/dumper/url_matcher1.php', $dumper->dump(), '->dump() dumps basic routes to the correct PHP file.');
     // force HTTPS redirection
     $collection->add('secure', new Route('/secure', array(), array('_scheme' => 'https')));
     // force HTTP redirection
     $collection->add('nonsecure', new Route('/nonsecure', array(), array('_scheme' => 'http')));
     $this->assertStringEqualsFile(__DIR__ . '/../../Fixtures/dumper/url_matcher2.php', $dumper->dump(array('base_class' => 'Symfony\\Tests\\Component\\Routing\\Fixtures\\RedirectableUrlMatcher')), '->dump() dumps basic routes to the correct PHP file.');
 }
开发者ID:rfc1483,项目名称:padel,代码行数:56,代码来源:PhpMatcherDumperTest.php

示例5: getRouteCollection

 protected function getRouteCollection()
 {
     $collection = new RouteCollection();
     $collection->add('overriden', new Route('/overriden'));
     // defaults and requirements
     $collection->add('foo', new Route('/foo/{bar}', array('def' => 'test'), array('bar' => 'baz|symfony')));
     // method requirement
     $collection->add('bar', new Route('/bar/{foo}', array(), array('_method' => 'GET|head')));
     // GET method requirement automatically adds HEAD as valid
     $collection->add('barhead', new Route('/barhead/{foo}', array(), array('_method' => 'GET')));
     // simple
     $collection->add('baz', new Route('/test/baz'));
     // simple with extension
     $collection->add('baz2', new Route('/test/baz.html'));
     // trailing slash
     $collection->add('baz3', new Route('/test/baz3/'));
     // trailing slash with variable
     $collection->add('baz4', new Route('/test/{foo}/'));
     // trailing slash and method
     $collection->add('baz5', new Route('/test/{foo}/', array(), array('_method' => 'post')));
     // complex name
     $collection->add('baz.baz6', new Route('/test/{foo}/', array(), array('_method' => 'put')));
     // defaults without variable
     $collection->add('foofoo', new Route('/foofoo', array('def' => 'test')));
     // pattern with quotes
     $collection->add('quoter', new Route('/{quoter}', array(), array('quoter' => '[\']+')));
     // prefixes
     $collection1 = new RouteCollection();
     $collection1->add('overriden', new Route('/overriden1'));
     $collection1->add('foo1', new Route('/{foo}'));
     $collection1->add('bar1', new Route('/{bar}'));
     $collection2 = new RouteCollection();
     $collection2->addCollection($collection1, '/b\'b');
     $collection2->add('overriden', new Route('/overriden2'));
     $collection1 = new RouteCollection();
     $collection1->add('foo2', new Route('/{foo1}'));
     $collection1->add('bar2', new Route('/{bar1}'));
     $collection2->addCollection($collection1, '/b\'b');
     $collection->addCollection($collection2, '/a');
     // "dynamic" prefix
     $collection1 = new RouteCollection();
     $collection1->add('foo3', new Route('/{foo}'));
     $collection1->add('bar3', new Route('/{bar}'));
     $collection2 = new RouteCollection();
     $collection2->addCollection($collection1, '/b');
     $collection->addCollection($collection2, '/{_locale}');
     $collection->add('ababa', new Route('/ababa'));
     // some more prefixes
     $collection1 = new RouteCollection();
     $collection1->add('foo4', new Route('/{foo}'));
     $collection->addCollection($collection1, '/aba');
     return $collection;
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:53,代码来源:PhpMatcherDumperTest.php

示例6: load

 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add this loader twice');
     }
     $collection = new RouteCollection();
     $resource = __DIR__ . '/../Resources/config';
     $locator = new FileLocator($resource);
     $loader = new YamlFileLoader($locator);
     $collection->addCollection($loader->load('routing.yml'));
     $collection->addCollection($loader->load('routing_admin.yml'));
     $this->loaded = true;
     return $collection;
 }
开发者ID:c4d3r,项目名称:mcsuite-application-eyeofender,代码行数:14,代码来源:RouteLoader.php

示例7: load

 /**
  * {@inheritdoc}
  */
 public function load($data, $type = null)
 {
     $routeCollection = new RouteCollection();
     $routeCollection->addCollection($this->fileLoader->load('json_ld.xml'));
     $routeCollection->addCollection($this->fileLoader->load('hydra.xml'));
     foreach ($this->resourceCollection as $resource) {
         foreach ($resource->getCollectionOperations() as $operation) {
             $routeCollection->add($operation->getRouteName(), $operation->getRoute());
         }
         foreach ($resource->getItemOperations() as $operation) {
             $routeCollection->add($operation->getRouteName(), $operation->getRoute());
         }
     }
     return $routeCollection;
 }
开发者ID:reminec,项目名称:DunglasApiBundle,代码行数:18,代码来源:ApiLoader.php

示例8: load

 /**
  * @todo clean this
  */
 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add this loader twice');
     }
     $routes = new RouteCollection();
     $frontPageConfig = $this->container->get('system')->get('system.frontpage', 'blog');
     $frontPageProvider = $this->container->get('drafterbit_system.frontpage_provider');
     $reservedBaseUrl = [$this->container->getParameter('admin')];
     foreach ($frontPageProvider->all() as $prefix => $frontPage) {
         $frontRoutes = $frontPage->getRoutes();
         if ($prefix !== $frontPageConfig) {
             $frontRoutes->addPrefix($frontPage->getRoutePrefix());
             $reservedBaseUrl[] = $prefix;
         }
         $routes->addCollection($frontRoutes);
     }
     $defaults = array('_controller' => 'DrafterbitPageBundle:Frontend:view');
     // check if configured frontpage is not an app
     if (!array_key_exists($frontPageConfig, $frontPageProvider->all())) {
         // its page
         $defaults['slug'] = $frontPageConfig;
         $routes->add('_home', new Route('/', $defaults));
     }
     $reservedBaseUrl = implode('|', $reservedBaseUrl);
     // @link http://stackoverflow.com/questions/25496704/regex-match-slug-except-particular-start-words
     // @prototype  'slug' => "^(?!(?:backend|blog)(?:/|$)).*$"
     $requirements = array('slug' => "^(?!(?:%admin%|" . $reservedBaseUrl . "|)(?:/|\$)).*\$");
     $route2 = new Route('/{slug}', $defaults, $requirements);
     $routes->add('misc', $route2);
     return $routes;
 }
开发者ID:hikmahtiar6,项目名称:drafterbit,代码行数:35,代码来源:FrontendLoader.php

示例9: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $type = null)
 {
     $collection = new RouteCollection();
     foreach ($this->localeResolver->getDomainConfig() as $_domain => $_locale) {
         $_collection = parent::load($resource, $type);
         foreach ($_collection->all() as $_name => $_route) {
             $_route->addDefaults(['_locale' => $_locale]);
             $_route->setHost($_domain);
             $collection->add($_locale . '__' . $this->urlizer->urlize($_domain, '_') . '__' . $_name, $_route);
         }
     }
     /*
      * Add default(fallback) route for default locale/domain
      * needs to be after the loop
      * */
     $defaultCollection = parent::load($resource, $type);
     $defaultCollection->addDefaults(['_locale' => $this->localeResolver->defaultLocale]);
     $collection->addCollection($defaultCollection);
     if ($this->localeResolver->localePattern == LocaleResolver::PATTERN_PARAMETER) {
         $collection = parent::load($resource, $type);
         //Prefix every victoire route with the locale
         $collection->addPrefix('/{_locale}');
         $collection->addCollection($collection);
         //Add a redirection to the default locale homepage when empty url '/'
         $this->addHomepageRedirection($collection);
     }
     return $collection;
 }
开发者ID:victoire,项目名称:victoire,代码行数:31,代码来源:I18nRouteLoader.php

示例10: load

 /**
  * @param string $resource
  * @param null $type
  * @return \Symfony\Component\Routing\RouteCollection
  */
 public function load($resource, $type = null)
 {
     $routes = new RouteCollection();
     $logger = $this->container->get('logger');
     $logger->info('Загрузка рубрик для построения роутинга');
     $a = microtime(true);
     $rubrics = $this->em->getRepository('ApplicationIphpCoreBundle:Rubric')->createQueryBuilder('r')->orderBy('r.level', 'DESC')->getQuery()->getResult();
     foreach ($rubrics as $rubric) {
         $controller = $rubric->getControllerName();
         $rubricRoutes = null;
         //В контроллере можеть быть: Класс модуля
         if ($controller && substr($controller, -6) == 'Module') {
             $module = $this->moduleManager->getModuleFromRubric($rubric);
             if ($module) {
                 $rubricRoutes = $module->getRoutes();
             }
         }
         if ($rubricRoutes) {
             foreach ($rubricRoutes as $route) {
                 $route->setDefault('_rubric', $rubric->getFullPath());
             }
             $routes->addCollection($rubricRoutes, substr($rubric->getFullPath(), 0, -1));
         }
     }
     $b = microtime(true) - $a;
     $logger->info('Загрузили роуты за' . $b . ' с');
     return $routes;
 }
开发者ID:khasinski,项目名称:Iphp,代码行数:33,代码来源:RubricRouteLoader.php

示例11: load

 /**
  * Loads a Yaml file.
  *
  * @param string $file A Yaml file path
  * @param string $type The resource type
  *
  * @return RouteCollection A RouteCollection instance
  *
  * @throws \InvalidArgumentException When route can't be parsed
  */
 public function load($file, $type = null)
 {
     $path = $this->findFile($file);
     $config = $this->loadFile($path);
     $collection = new RouteCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $config) {
         $config = array();
     }
     // not an array
     if (!is_array($config)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file));
     }
     foreach ($config as $name => $config) {
         if (isset($config['resource'])) {
             $type = isset($config['type']) ? $config['type'] : null;
             $prefix = isset($config['prefix']) ? $config['prefix'] : null;
             $this->currentDir = dirname($path);
             $collection->addCollection($this->import($config['resource'], $type), $prefix);
         } elseif (isset($config['pattern'])) {
             $this->parseRoute($collection, $name, $config, $path);
         } else {
             throw new \InvalidArgumentException(sprintf('Unable to parse the "%s" route.', $name));
         }
     }
     return $collection;
 }
开发者ID:notbrain,项目名称:symfony,代码行数:38,代码来源:YamlFileLoader.php

示例12: addGroup

 public function addGroup($config, $callback)
 {
     $router = $this->getSubRouter();
     if (is_callable($callback)) {
         $callback($router);
     } else {
         $e = new Error();
         $e->log(new \Exception('Segundo parâmetro não é uma função do tipo callable'));
     }
     $sub_collection = $router->getCollection();
     if (isset($config['defaults'])) {
         $sub_collection->addDefaults($config['defaults']);
     }
     if (isset($config['mask'])) {
         $sub_collection->addRequirements($config['mask']);
     }
     if (isset($config['options'])) {
         $sub_collection->addOptions($config['options']);
     }
     if (isset($config['host'])) {
         $sub_collection->setHost($config['host']);
     }
     if (isset($config['schemes'])) {
         $sub_collection->setSchemes($config['schemes']);
     }
     if (isset($config['methods'])) {
         $sub_collection->setMethods($config['methods']);
     }
     $this->collection->addCollection($sub_collection);
 }
开发者ID:anna-framework,项目名称:anna,代码行数:30,代码来源:RouterTrait.php

示例13: load

 /**
  * Loads a Yaml file.
  *
  * @param string $file A Yaml file path
  * @param string $type The resource type
  *
  * @return RouteCollection A RouteCollection instance
  *
  * @throws \InvalidArgumentException When route can't be parsed
  *
  * @api
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     $config = Yaml::parse($path);
     $collection = new RouteCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $config) {
         $config = array();
     }
     // not an array
     if (!is_array($config)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file));
     }
     foreach ($config as $name => $config) {
         $config = $this->normalizeRouteConfig($config);
         if (isset($config['resource'])) {
             $type = isset($config['type']) ? $config['type'] : null;
             $prefix = isset($config['prefix']) ? $config['prefix'] : null;
             $defaults = isset($config['defaults']) ? $config['defaults'] : array();
             $requirements = isset($config['requirements']) ? $config['requirements'] : array();
             $options = isset($config['options']) ? $config['options'] : array();
             $this->setCurrentDir(dirname($path));
             $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options);
         } else {
             $this->parseRoute($collection, $name, $config, $path);
         }
     }
     return $collection;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:42,代码来源:YamlFileLoader.php

示例14: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $type = null)
 {
     if (true === $this->isLoaded) {
         throw new \RuntimeException('Do not add the "modera_routing" loader twice');
     }
     $resources = array();
     $items = $this->resourcesProvider->getItems();
     foreach ($items as $index => $resource) {
         if (!is_array($resource)) {
             $resource = array('resource' => $resource);
         }
         $resource = array_merge(array('order' => 0, 'type' => null), $resource);
         $resource['index'] = $index;
         $resources[] = $resource;
     }
     usort($resources, function ($a, $b) {
         if ($a['order'] == $b['order']) {
             return $a['index'] < $b['index'] ? -1 : 1;
         }
         return $a['order'] < $b['order'] ? -1 : 1;
     });
     $collection = new RouteCollection();
     foreach ($resources as $item) {
         $collection->addCollection($this->rootLoader->load($item['resource'], $item['type']));
     }
     $this->isLoaded = true;
     return $collection;
 }
开发者ID:modera,项目名称:foundation,代码行数:31,代码来源:Loader.php

示例15: loadRouteCollectionFromFiles

 /**
  * @param string[] $paths
  */
 protected function loadRouteCollectionFromFiles(array $paths) : RouteCollection
 {
     $routeCollection = new RouteCollection();
     foreach ($paths as $path) {
         $routeCollection->addCollection($this->loadRouteCollectionFromFile($path));
     }
     return $routeCollection;
 }
开发者ID:Symplify,项目名称:ModularRouting,代码行数:11,代码来源:AbstractRouteCollectionProvider.php


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