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


PHP Router::scope方法代码示例

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


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

示例1: tearDown

 /**
  * Clean up after the test.
  */
 public function tearDown()
 {
     Router::reset();
     foreach ($this->_routes as $scope => $routes) {
         Router::scope($scope, function () use($routes) {
             foreach ($routes as $route) {
                 Router::connect($route);
             }
         });
     }
     unset($this->html);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:15,代码来源:HtmlTest.php

示例2: _restoreCtrlContext

 protected function _restoreCtrlContext()
 {
     Router::reset();
     foreach ($this->_context['routes'] as $scope => $routes) {
         Router::scope($scope, function () use($routes) {
             foreach ($routes as $route) {
                 Router::connect($route);
             }
         });
     }
     foreach ($this->_context['scopes'] as $scope => $attachment) {
         Router::attach($scope, $attachment);
     }
     Router::scope($this->_context['scope']);
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:15,代码来源:Controller.php

示例3: testMatchOverRequestParamsWithScope

 public function testMatchOverRequestParamsWithScope()
 {
     Router::scope('app1', function () {
         Router::connect('/hello/world1', 'HelloApp1::index');
     });
     Router::scope('app2', function () {
         Router::connect('/hello/world2', 'HelloApp2::index');
     });
     $request = new Request(array('url' => '/hello/world1'));
     $result = Router::process($request);
     $expected = array('controller' => 'HelloApp1', 'action' => 'index', 'library' => 'app1');
     $this->assertEqual($expected, $result->params);
     $result = Router::match($result->params);
     $this->assertEqual('/hello/world1', $result);
     $request = new Request(array('url' => '/hello/world2'));
     $result = Router::process($request);
     $expected = array('controller' => 'HelloApp2', 'action' => 'index', 'library' => 'app2');
     $this->assertEqual($expected, $result->params);
     $result = Router::match($result->params);
     $this->assertEqual('/hello/world2', $result);
 }
开发者ID:rapzo,项目名称:lithium,代码行数:21,代码来源:RouterTest.php

示例4: testMatchWithScopeAndWithoutController

 public function testMatchWithScopeAndWithoutController()
 {
     Router::scope('app', function () {
         Router::connect('/{:id}', 'Posts::index');
     });
     $request = new Request(array('url' => '/1', 'base' => ''));
     MockDispatcher::run($request);
     $result = Router::match(array('id' => 2), $request);
     $this->assertEqual('/2', $result);
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:10,代码来源:RouterTest.php

示例5: testRouteRetrievalWithScope

 public function testRouteRetrievalWithScope()
 {
     Router::scope('loc1', function () use(&$expected) {
         $expected = Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
     });
     $result = Router::get(0, true);
     $this->assertIdentical(null, $result);
     $result = Router::get(0, 'loc1');
     $this->assertIdentical($expected, $result);
     Router::scope('loc1', function () {
         Router::connect('/helloworld', array('controller' => 'Posts', 'action' => 'index'));
     });
     Router::scope('loc2', function () {
         Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
     });
     $this->assertCount(0, Router::get(null, true));
     $result = count(Router::get(null, 'loc1'));
     $this->assertCount(2, Router::get(null, 'loc1'));
     $scopes = Router::get();
     $result = 0;
     foreach ($scopes as $routes) {
         $result += count($routes);
     }
     $this->assertIdentical(3, $result);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:25,代码来源:RouterTest.php


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