\Ceo\Api\ControllersBatchController

Batch controller

Allows for calling multiple commands in a single request. Commands run in the form of a hash with the request URI and the request params:

[
  [
     "PUT:/v3/content",
     {...}
  ],
  [
     "POST:/v3/content/123-345-123",
     {...}
  ]
]

Responses will be returned as an array of data, status codes and URIs matched to the request:

[
  {
     "uri": "PUT:/v3/content",
     "response": {...}
     "status": 200
  },
  {
     "uri": "POST:/v3/content/123-345-123",
     "response": "You do not have permission"
     "status": 403
  },
]

Standard ACL rules still apply.

Summary

Methods
Properties
Constants
getStatusCode()
getHeaders()
getPayload()
setStatusCode()
setHeaders()
setPayload()
startBatchMode()
endBatchMode()
indexAction()
listAction()
$batchMode
$batchedResponses
No constants found
initResponse()
_getContent()
getJsonData()
output()
getHttpCodeDescription()
render()
renderException()
$statusCode
$headers
$payload
$format
$responses
N/A
No private methods found
No private properties found
N/A

Properties

$batchMode

$batchMode : boolean

Controller is in batch mode

Type

boolean

$batchedResponses

$batchedResponses : array

Stack for batched responses

Type

array

$statusCode

$statusCode : integer

Status code

Type

integer

$headers

$headers : array

Default headers

Type

array

$payload

$payload : string

Response payload

Type

string

$format

$format : string

Response format, always json

Type

string

$responses

$responses : 

Type

Methods

getStatusCode()

getStatusCode() : integer

Return status code

Returns

integer

getHeaders()

getHeaders() : array

Return current headers

Returns

array

getPayload()

getPayload() : string

Return payload

Returns

string

setStatusCode()

setStatusCode(integer  $code) 

Set status code

Parameters

integer $code

HTTP status code

setHeaders()

setHeaders(string  $key, string  $value) 

Set header value

Parameters

string $key

Header name

string $value

Header value

setPayload()

setPayload(string  $payload) 

Set payload

Parameters

string $payload

startBatchMode()

startBatchMode() 

Static method to enable batch mode return handling

endBatchMode()

endBatchMode() 

Static method to disable batch mode return handling

indexAction()

indexAction() 

listAction()

listAction() 

initResponse()

initResponse(integer  $status = 200) 

Reset response headers and payload

Parameters

integer $status

HTTP status code

_getContent()

_getContent(mixed  $payload) : string

Return json encoded string

Parameters

mixed $payload

Payload

Returns

string

getJsonData()

getJsonData() : array

Fetch POSTed/PUTed json data

Returns

array

output()

output() : \Ceo\Core\Controllers\Phalcon\Http\Response

Output the valid response, headers, status code and payload

Returns

\Ceo\Core\Controllers\Phalcon\Http\Response

getHttpCodeDescription()

getHttpCodeDescription(integer  $code) : string

Get http code description text based on code value

Parameters

integer $code

Returns

string

render()

render(string  $st_output, integer  $statusCode = 200) : \Ceo\Core\Controllers\Phalcon\Http\Response

Render output, resets headers and status code.

If batch mode is enabled, will return an array with status code and response.

Parameters

string $st_output

Output string

integer $statusCode

HTTP status code

Returns

\Ceo\Core\Controllers\Phalcon\Http\Response

renderException()

renderException(\Ceo\Core\Controllers\Exception  $e) : \Ceo\Core\Controllers\Phalcon\Http\Response

Render a trapped exception

Parameters

\Ceo\Core\Controllers\Exception $e

Returns

\Ceo\Core\Controllers\Phalcon\Http\Response