StreamResponse
in package
This class is used to build up a stream array or json response used in stream actions.
Tags
Table of Contents
Properties
- $entries : array<string|int, mixed>
- $entryOrder : array<string|int, mixed>
- $error : string
- $errorCode : int
- $lastContentId : int
- $result : array<string|int, mixed>
- $streamQuery : StreamQuery
Methods
- __construct() : mixed
- StreamResponse constructor.
- addEntry() : mixed
- Adds entries to the response by providing either an response array or a StreamEntryResponse instance.
- asArray() : array<string|int, mixed>
- Returns the stream response array.
- asJson() : Response
- Returns the stream action result as json response.
- setError() : mixed
- Can be used to set error information.
- isLast() : mixed
Properties
$entries
public
array<string|int, mixed>
$entries
= []
contains the result array of the different entries
$entryOrder
public
array<string|int, mixed>
$entryOrder
= []
contains the order of entries
$error
public
string
$error
$errorCode
public
int
$errorCode
$lastContentId
private
int
$lastContentId
$result
private
array<string|int, mixed>
$result
= []
resulting array
$streamQuery
private
StreamQuery
$streamQuery
the StreamQuery used to fetch the entries
Methods
__construct()
StreamResponse constructor.
public
__construct(StreamQuery $streamQuery) : mixed
Parameters
- $streamQuery : StreamQuery
addEntry()
Adds entries to the response by providing either an response array or a StreamEntryResponse instance.
public
addEntry(array<string|int, mixed>|StreamEntryResponse $entry[, bool|int $injectIndex = false ]) : mixed
An $entry array needs at least to provide a id
and output
value. When injecting an entry outside of the
stream query result the $injectIndex should be set to either an existing result index or to true. This will
make sure the injected entry will be ignored in the stream flow (load more).
Parameters
- $entry : array<string|int, mixed>|StreamEntryResponse
- $injectIndex : bool|int = false
Tags
asArray()
Returns the stream response array.
public
asArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>asJson()
Returns the stream action result as json response.
public
asJson() : Response
Tags
Return values
ResponsesetError()
Can be used to set error information.
public
setError(mixed $code, mixed $msg) : mixed
Parameters
- $code : mixed
-
int
- $msg : mixed
-
string
isLast()
private
isLast(mixed $isLast) : mixed
Parameters
- $isLast : mixed
-
bool sets the isLast flag of the response