PHP Class Cml\Service\Route

Inheritance: implements Cml\Interfaces\Route
Show file Open project: linhecheng/cmlphp

Public Methods

Method Description
any ( string $pattern, string | array $action ) 增加任意访问方式路由
delete ( string $pattern, string | array $action ) 增加delete访问方式路由
get ( string $pattern, string | array $action ) 增加get访问方式路由
getActionName ( ) : string 获取控制器名称方法名称
getAppName ( ) : string 获取应用目录可以是多层目录。如web、admin等.404的时候也必须有值用于绑定系统命令
getControllerAndAction ( ) 获取要执行的控制器类名及方法
getControllerName ( ) : string 获取控制器名称不带Controller后缀
getFullPathNotContainSubDir ( ) : string 获取不含子目录的完整路径 如: web/Goods/add
getSubDirName ( ) : string 获取子目录路径。若项目在子目录中的时候为子目录的路径如/sub_dir/、否则为/
group ( string $namespace, callable $func ) 分组路由
options ( string $pattern, string | array $action ) 增加options访问方式路由
parseUrl ( ) : void 解析url
patch ( string $pattern, string | array $action ) 增加patch访问方式路由
post ( string $pattern, string | array $action ) 增加post访问方式路由
put ( string $pattern, string | array $action ) 增加put访问方式路由
rest ( string $pattern, string | array $action ) 增加REST方式路由

Private Methods

Method Description
findAction ( array &$pathInfo, string &$path ) 从文件查找控制器
isRoute ( string &$pathInfo ) : mixed 匹配路由
patternFactory ( $pattern ) : string 组装路由规则

Method Details

any() public method

增加任意访问方式路由
public any ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

delete() public method

增加delete访问方式路由
public delete ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

get() public method

增加get访问方式路由
public get ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

getActionName() public method

获取控制器名称方法名称
public getActionName ( ) : string
return string

getAppName() public method

获取应用目录可以是多层目录。如web、admin等.404的时候也必须有值用于绑定系统命令
public getAppName ( ) : string
return string

getControllerAndAction() public method

获取要执行的控制器类名及方法

getControllerName() public method

获取控制器名称不带Controller后缀
public getControllerName ( ) : string
return string

getFullPathNotContainSubDir() public method

获取不含子目录的完整路径 如: web/Goods/add

getSubDirName() public method

获取子目录路径。若项目在子目录中的时候为子目录的路径如/sub_dir/、否则为/
public getSubDirName ( ) : string
return string

group() public method

分组路由
public group ( string $namespace, callable $func )
$namespace string 分组名
$func callable 闭包

options() public method

增加options访问方式路由
public options ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

parseUrl() public method

解析url
public parseUrl ( ) : void
return void

patch() public method

增加patch访问方式路由
public patch ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

post() public method

增加post访问方式路由
public post ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

put() public method

增加put访问方式路由
public put ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作

rest() public method

增加REST方式路由
public rest ( string $pattern, string | array $action )
$pattern string 路由规则
$action string | array 执行的操作