本文整理汇总了PHP中lithium\net\http\Router::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::attach方法的具体用法?PHP Router::attach怎么用?PHP Router::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\net\http\Router
的用法示例。
在下文中一共展示了Router::attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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']);
}
示例2: testMatchWithAbsoluteScope
public function testMatchWithAbsoluteScope()
{
Router::attach('app', array('absolute' => true, 'host' => '{:domain}'));
Router::scope('app', function () {
Router::connect('/hello', 'Posts::index');
});
$request = new Request(array('url' => '/hello', 'base' => ''));
$result = Router::process($request);
$expected = 'http://' . $result->params['domain'] . '/hello';
$result = Router::match($result->params, $request);
$this->assertEqual($expected, $result);
}
示例3: testScopeBase
public function testScopeBase()
{
$request = new Request(array('base' => 'lithium/app'));
$url = array('controller' => 'HelloWorld');
Router::scope('app', function () {
Router::connect('/{:controller}/{:action}');
});
Router::scope('app');
$expected = '/lithium/app/hello_world';
$this->assertEqual($expected, Router::match($url, $request));
Router::attach('app', array('base' => 'lithium'));
$expected = '/lithium/hello_world';
$this->assertEqual($expected, Router::match($url, $request));
Router::attach('app', array('base' => ''));
$expected = '/hello_world';
$this->assertEqual($expected, Router::match($url, $request));
}