Route类原来的alias方法更名为controller,路由增加别名方法 alias 支持使用别名简化路由定义,例如:

// 使用 user 路由别名指向 index模块的user控制器
Route::alias('user','index/user');
This commit is contained in:
thinkphp
2016-06-08 17:50:54 +08:00
parent 27bd976916
commit 0b16a5c5a3
2 changed files with 123 additions and 21 deletions

View File

@@ -138,7 +138,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
{
$request = Request::instance();
Route::get('user/:name', '\app\index\service\User::get', [], ['name' => '\w+']);
Route::get('info/:name', ['\app\index\model\Info', 'getInfo'], [], ['name' => '\w+']);
Route::get('info/:name', '\app\index\model\Info@getInfo', [], ['name' => '\w+']);
$this->assertEquals(['type' => 'method', 'method' => '\app\index\service\User::get', 'params' => ['name' => 'thinkphp']], Route::check($request, 'user/thinkphp'));
$this->assertEquals(['type' => 'method', 'method' => ['\app\index\model\Info', 'getInfo'], 'params' => ['name' => 'thinkphp']], Route::check($request, 'info/thinkphp'));
}