\RestAction

ThinkPHP Restful 控制器扩展

Summary

Methods
Properties
Constants
__construct()
__call()
__set()
setContentType()
No public properties found
No constants found
getActionName()
isAjax()
display()
assign()
response()
encodeData()
sendHttpStatus()
getAcceptType()
$view
$_method
$_type
$_types
N/A
No private methods found
$name
N/A

Properties

$view

$view : 

Type

$_method

$_method : 

Type

$_type

$_type : 

Type

$_types

$_types : 

Type

$name

$name : 

Type

Methods

__construct()

__construct() 

架构函数 取得模板对象实例

__call()

__call(string  $method, array  $args) : mixed

魔术方法 有不存在的操作的时候执行

Parameters

string $method

方法名

array $args

参数

Returns

mixed

__set()

__set(  $name,   $value) 

Parameters

$name
$value

setContentType()

setContentType(string  $type, string  $charset = '') : void

设置页面输出的CONTENT_TYPE和编码

Parameters

string $type

content_type 类型对应的扩展名

string $charset

页面输出编码

getActionName()

getActionName() 

获取当前Action名称

isAjax()

isAjax() : boolean

是否AJAX请求

Returns

boolean

display()

display(string  $templateFile = '', string  $charset = '', string  $contentType = '') : void

模板显示 调用内置的模板引擎显示方法,

Parameters

string $templateFile

指定要调用的模板文件 默认为空 由系统自动定位模板文件

string $charset

输出编码

string $contentType

输出类型

assign()

assign(mixed  $name, mixed  $value = '') : void

模板变量赋值

Parameters

mixed $name

要显示的模板变量

mixed $value

变量的值

response()

response(mixed  $data, String  $type = '', integer  $code = 200) : void

输出返回数据

Parameters

mixed $data

要返回的数据

String $type

返回类型 JSON XML

integer $code

HTTP状态

encodeData()

encodeData(mixed  $data, String  $type = '') : void

编码数据

Parameters

mixed $data

要返回的数据

String $type

返回类型 JSON XML

sendHttpStatus()

sendHttpStatus(  $status) 

Parameters

$status

getAcceptType()

getAcceptType() : string

获取当前请求的Accept头信息

Returns

string