本文整理汇总了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);
}
示例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']);
}
示例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);
}
示例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);
}
示例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);
}