controller() public static method

注册控制器路由 操作方法对应不同的请求后缀
public static controller ( string $rule, string $route = '', array $option = [], array $pattern = [] ) : void
$rule string 路由规则
$route string 路由地址
$option array 路由参数
$pattern array 变量规则
return void
Exemplo n.º 1
0
 public function testControllerRoute()
 {
     $request = Request::instance();
     Route::controller('controller', 'index/Blog');
     $result = Route::check($request, 'controller/info');
     $this->assertEquals(['index', 'Blog', 'getinfo'], $result['module']);
     Route::setMethodPrefix('GET', 'read');
     Route::setMethodPrefix(['get' => 'read']);
     Route::controller('controller', 'index/Blog');
     $result = Route::check($request, 'controller/phone');
     $this->assertEquals(['index', 'Blog', 'readphone'], $result['module']);
 }