CrossPHP

Controller extends FrameBase
in package

Tags
author

wonli wonli@live.com Class Controller

Table of Contents

$appDelegate  : Delegate
$config  : Config
$request  : Request
$response  : Response
$view  : View
$action  : string
action名称
$actionAnnotate  : array<string|int, mixed>
当前方法的注释配置
$controller  : string
控制器名称
$data  : array<string|int, mixed>
默认数据
$delegate  : Delegate
$params  : array<string|int, mixed>
参数列表
$statusConfigFile  : string
状态配置文件
$viewController  : string
视图控制器命名空间
__construct()  : mixed
Controller constructor.
__get()  : Response|Request|View|Config|null
request response view
getConfig()  : Config
getDelegate()  : Delegate
getFilePath()  : string
解析文件路径 <pre> 格式如下: 1 ::[path/file_name] 从当前项目根目录查找 2 app::[path/file_name] 当前app路径 3 static::[path/file_name] 静态资源目录 4 cache::[path/file_name] 缓存路径 5 config::[path/file_name] 配置路径 </pre>
input()  : DataFilter
获取输入数据
loadConfig()  : Config
读取配置文件
parseGetFile()  : mixed
获取文件路径
responseData()  : ResponseData
返回一个ResponseData对象
setAction()  : self
重设视图action名称
display()  : void
视图渲染
end()  : mixed
发送一个错误状态
getAuth()  : bool|mixed|string
解密会话
getResponseData()  : ResponseData
交互数据对齐
getStatusMessage()  : string
获取消息状态内容
getUrlEncryptKey()  : string
获取uri加密/解密时用到的key
initView()  : mixed
初始化视图控制器
isAjax()  : bool
判断是否AJAX请求
isCli()  : bool
是否在命令行下执行
isGet()  : bool
判断是否GET请求
isPost()  : bool
判断是否POST请求
json()  : mixed
发送JSON数据
redirect()  : void
重定向
returnReferer()  : void
返回执行的前一页
setAuth()  : bool
加密会话 <pre> sys.auth 中指定cookie/session </pre>
sParams()  : array<string|int, mixed>|bool|string
还原加密后的参数
to()  : void
重定向到指定的控制器
urlEncrypt()  : bool|string
uri参数加密

Properties

$action

action名称

protected string $action

$actionAnnotate

当前方法的注释配置

protected array<string|int, mixed> $actionAnnotate

$controller

控制器名称

protected string $controller

$data

默认数据

protected array<string|int, mixed> $data = []

$params

参数列表

protected array<string|int, mixed> $params

$statusConfigFile

状态配置文件

protected string $statusConfigFile = 'config::status.config.php'

$viewController

视图控制器命名空间

protected string $viewController

Methods

__construct()

Controller constructor.

public __construct() : mixed
Return values
mixed

getFilePath()

解析文件路径 <pre> 格式如下: 1 ::[path/file_name] 从当前项目根目录查找 2 app::[path/file_name] 当前app路径 3 static::[path/file_name] 静态资源目录 4 cache::[path/file_name] 缓存路径 5 config::[path/file_name] 配置路径 </pre>

public getFilePath(string $name) : string
Parameters
$name : string
Return values
string

input()

获取输入数据

public input(string $key[, mixed $default = null ]) : DataFilter
Parameters
$key : string
$default : mixed = null
Return values
DataFilter

parseGetFile()

获取文件路径

public parseGetFile(string $name[, bool $getFileContent = false ]) : mixed
Parameters
$name : string
$getFileContent : bool = false
Tags
throws
CoreException
see
Loader::read()
Return values
mixed

responseData()

返回一个ResponseData对象

public responseData([int $status = 1 ][, array<string|int, mixed> $data = [] ]) : ResponseData
Parameters
$status : int = 1
$data : array<string|int, mixed> = []
Return values
ResponseData

setAction()

重设视图action名称

public setAction(string $actionName) : self
Parameters
$actionName : string
Return values
self

display()

视图渲染

protected display([mixed $data = null ][, string|null $method = null ][, int $httpResponseStatus = 200 ]) : void
Parameters
$data : mixed = null
$method : string|null = null
$httpResponseStatus : int = 200
Tags
throws
CoreException
see
View::display()
Return values
void

end()

发送一个错误状态

protected end(int $status[, mixed $message = null ]) : mixed
Parameters
$status : int
$message : mixed = null
Tags
throws
CoreException|LogicStatusException
Return values
mixed

getAuth()

解密会话

protected getAuth(string $key[, bool $deCode = false ]) : bool|mixed|string
Parameters
$key : string
$deCode : bool = false
Tags
throws
CoreException
Return values
bool|mixed|string

getStatusMessage()

获取消息状态内容

protected getStatusMessage(int $status) : string
Parameters
$status : int
Tags
throws
CoreException
Return values
string

getUrlEncryptKey()

获取uri加密/解密时用到的key

protected getUrlEncryptKey([string $type = 'auth' ]) : string
Parameters
$type : string = 'auth'
Return values
string

initView()

初始化视图控制器

protected initView() : mixed
Return values
mixed

isAjax()

判断是否AJAX请求

protected isAjax() : bool
Return values
bool

isCli()

是否在命令行下执行

protected isCli() : bool
Return values
bool

isGet()

判断是否GET请求

protected isGet() : bool
Return values
bool

isPost()

判断是否POST请求

protected isPost() : bool
Return values
bool

json()

发送JSON数据

protected json(int $status[, array<string|int, mixed> $data = [] ]) : mixed
Parameters
$status : int
$data : array<string|int, mixed> = []
Return values
mixed

redirect()

重定向

protected redirect(string $url[, int $httpResponseStatus = 302 ]) : void
Parameters
$url : string
$httpResponseStatus : int = 302
Tags
see
Response::redirect
Return values
void

returnReferer()

返回执行的前一页

protected returnReferer() : void
Return values
void

setAuth()

加密会话 <pre> sys.auth 中指定cookie/session </pre>

protected setAuth(string $key, string|array<string|int, mixed> $value[, int $expire = 86400 ]) : bool
Parameters
$key : string

key

$value : string|array<string|int, mixed>

$expire : int = 86400

过期时间(默认一天过期)

Tags
throws
CoreException
Return values
bool

sParams()

还原加密后的参数

protected sParams([bool $useAnnotate = true ][, null|string $params = null ]) : array<string|int, mixed>|bool|string
Parameters
$useAnnotate : bool = true
$params : null|string = null
Return values
array<string|int, mixed>|bool|string

to()

重定向到指定的控制器

protected to([string|null $controller = null ][, string|array<string|int, mixed>|null $params = null ][, bool $sec = false ]) : void
Parameters
$controller : string|null = null

controller:action

$params : string|array<string|int, mixed>|null = null
$sec : bool = false
Tags
throws
CoreException
Return values
void

urlEncrypt()

uri参数加密

protected urlEncrypt(string $params[, string $type = 'encode' ]) : bool|string
Parameters
$params : string
$type : string = 'encode'
Return values
bool|string

Search results