JsonHelper
A trait that can be used by controllers who need to return typical JSON
Instance Methods
| Returns | Signature and Description | 
|---|---|
| ResponseInterface | sendCreated(,,,)Send notice that an entity was created. | 
| ResponseInterface | sendDeleted(,,,)Send notice that objects were deleted. | 
| ResponseInterface | sendItems<T>(,,,)Sends a Content-Range header for pagination | 
| ResponseInterface | sendJson(,)Send something as JSON | 
| ResponseInterface | sendUpdated(,,,)Send notice that objects were updated. | 
| ResponseInterface | sendVerb(,,,,)Sends a generic notice that objects have been operated on | 
Method Details
sendCreated
sendCreated(ResponseInterface $responsestring $typeConstVector<string> $idsConstMap<string,mixed> $extra = ImmMap{}Send notice that an entity was created.
| Name | Type | Description | 
|---|---|---|
| $response | ResponseInterface | The response | 
| $type | string | The entity type | 
| $ids | ConstVector<string> | |
| $extra | ConstMap<string,mixed> | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response | 
sendDeleted
sendDeleted(ResponseInterface $responsestring $typeConstVector<string> $idsConstMap<string,mixed> $extra = ImmMap{}Send notice that objects were deleted.
| Name | Type | Description | 
|---|---|---|
| $response | ResponseInterface | The response | 
| $type | string | The entity type | 
| $ids | ConstVector<string> | The entity ids | 
| $extra | ConstMap<string,mixed> | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response | 
sendItems
sendItems<T>(ResponseInterface $responseTraversable<T> $items?Pagination $pagination = null?int $total = nullSends a Content-Range header for pagination
- Since
- 0.6.0
| Name | Type | Description | 
|---|---|---|
| $response | ResponseInterface | The response | 
| $items | Traversable<T> | |
| $pagination | ?Pagination | |
| $total | ?int | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response | 
sendJson
sendJson(ResponseInterface $responsemixed $payloadSend something as JSON
| Name | Type | Description | 
|---|---|---|
| $response | ResponseInterface | The response | 
| $payload | mixed | The object to serialize | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response | 
sendUpdated
sendUpdated(ResponseInterface $responsestring $typeConstVector<string> $idsConstMap<string,mixed> $extra = ImmMap{}Send notice that objects were updated.
| Name | Type | Description | 
|---|---|---|
| $response | ResponseInterface | The response | 
| $type | string | The entity type | 
| $ids | ConstVector<string> | The entity ids | 
| $extra | ConstMap<string,mixed> | Any extra data to serialize | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response | 
sendVerb
sendVerb(string $verbResponseInterface $responsestring $typeConstVector<string> $idsConstMap<string,mixed> $extra = ImmMap{}Sends a generic notice that objects have been operated on
| Name | Type | Description | 
|---|---|---|
| $verb | string | The verb | 
| $response | ResponseInterface | The response | 
| $type | string | The entity type | 
| $ids | ConstVector<string> | The entity ids | 
| $extra | ConstMap<string,mixed> | Any extra data to serialize | 
| Type | Description | 
|---|---|
| ResponseInterface | The JSON response |