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


PHP RouteCollection::getRoute方法代码示例

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


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

示例1: testAddPrefix

 public function testAddPrefix()
 {
     $collection = new RouteCollection();
     $collection->addRoute('foo', $foo = new Route('/foo'));
     $collection->addRoute('bar', $bar = new Route('/bar'));
     $collection->addPrefix('/admin');
     $this->assertEquals('/admin/foo', $collection->getRoute('foo')->getPattern(), '->addPrefix() adds a prefix to all routes');
     $this->assertEquals('/admin/bar', $collection->getRoute('bar')->getPattern(), '->addPrefix() adds a prefix to all routes');
 }
开发者ID:netixpro,项目名称:symfony,代码行数:9,代码来源:RouteCollectionTest.php

示例2: testLoad

 /**
  * @covers Symfony\Component\Routing\Loader\ClosureLoader::load
  */
 public function testLoad()
 {
     $loader = new ClosureLoader();
     $route = new Route('/');
     $routes = $loader->load(function () use($route) {
         $routes = new RouteCollection();
         $routes->addRoute('foo', $route);
         return $routes;
     });
     $this->assertEquals($route, $routes->getRoute('foo'), '->load() loads a \\Closure resource');
 }
开发者ID:netixpro,项目名称:symfony,代码行数:14,代码来源:ClosureLoaderTest.php

示例3: testLoad

 /**
  * @covers Symfony\Component\Routing\Loader\DelegatingLoader::load
  */
 public function testLoad()
 {
     $resolver = new LoaderResolver(array(new ClosureLoader()));
     $loader = new DelegatingLoader($resolver);
     $route = new Route('/');
     $routes = $loader->load(function () use($route) {
         $routes = new RouteCollection();
         $routes->addRoute('foo', $route);
         return $routes;
     });
     $this->assertSame($route, $routes->getRoute('foo'), '->load() loads a resource using the loaders from the resolver');
     try {
         $loader->load('foo.foo');
         $this->fail('->load() throws an \\InvalidArgumentException if the resource cannot be loaded');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an \\InvalidArgumentException if the resource cannot be loaded');
     }
 }
开发者ID:netixpro,项目名称:symfony,代码行数:21,代码来源:DelegatingLoaderTest.php


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