ApiTrait
Additional functionality for API controllers.
Tags
Table of Contents
- $jsonpCallback : string
- Callback function in JSONP mode
- $jsonPrettyPrint : bool
- Whether to pretty-print JSON
- $outputMode : string
- Type of output to use
- onDispatch() : mixed
- Execute the request
- determineOutputMode() : void
- Determine the correct output mode based on content negotiation or the view parameter
- isAccessDenied() : Response|bool
- Check whether access is denied and return the appropriate message or false.
- output() : Response
- Send output data and exit.
Properties
$jsonpCallback
Callback function in JSONP mode
protected
string
$jsonpCallback
= null
$jsonPrettyPrint
Whether to pretty-print JSON
protected
bool
$jsonPrettyPrint
= false
$outputMode
Type of output to use
protected
string
$outputMode
= 'json'
Methods
onDispatch()
Execute the request
public
onDispatch(MvcEvent $e) : mixed
Parameters
- $e : MvcEvent
-
Event
Tags
Return values
mixed —determineOutputMode()
Determine the correct output mode based on content negotiation or the view parameter
protected
determineOutputMode() : void
Return values
void —isAccessDenied()
Check whether access is denied and return the appropriate message or false.
protected
isAccessDenied(string $permission) : Response|bool
Parameters
- $permission : string
-
Permission to check
Return values
Response|bool —output()
Send output data and exit.
protected
output(mixed $data, string $status[, int $httpCode = null ][, string $message = '' ]) : Response
Parameters
- $data : mixed
-
The response data
- $status : string
-
Status of the request
- $httpCode : int = null
-
A custom HTTP Status Code
- $message : string = ''
-
Status message