Detailed Description
JsonFormat implements the JSON request/response format.
All data will be serialized using the json_encode method except for Nodes. Nodes are serialized into an array before encoding (see JsonFormat::serializeValue) using the NodeSerializer class. On serialization the data will be outputted directly using the print command.
JsonFormat collects the response data from all executed controllers into one response array and returns it all at once at the end of script execution. This prevents from having multiple chunks of JSON from each controller response that can't be decoded by clients.
Definition at line 34 of file JsonFormat.php.
Public Member Functions | |
__construct (NodeSerializer $serializer, Cache $dynamicCache) | |
getMimeType (Response $response=null) | |
Public Member Functions inherited from AbstractFormat | |
deserialize (Request $request) | |
serialize (Response $response) | |
getResponseHeaders (Response $response) | |
Public Member Functions inherited from Format | |
isCached (Response $response) | |
getCacheDate (Response $response) | |
Public Attributes | |
const | CACHE_SECTION = 'jsonformat' |
Protected Member Functions | |
getCache () | |
getBaseCacheSection () | |
afterSerialize (Response $response) | |
isSerializedNode ($value) | |
serializeNode ($value) | |
deserializeNode ($value) | |
Protected Member Functions inherited from HierarchicalFormat | |
deserializeValues (Request $request) | |
serializeValues (Response $response) | |
isDeserializedNode ($value) | |
Protected Member Functions inherited from AbstractFormat | |
beforeDeserialize (Request $request) | |
afterDeserialize (Request $request) | |
beforeSerialize (Response $response) | |
getNode (ObjectId $oid) | |
filterValue ($value, AttributeDescription $attribute) | |
Protected Attributes | |
$cache = null | |
$serializer = null | |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | NodeSerializer | $serializer, |
Cache | $dynamicCache | ||
) |
Constructor.
- Parameters
-
$serializer NodeSerializer instance $dynamicCache Cache instance
Definition at line 49 of file JsonFormat.php.
Member Function Documentation
◆ getMimeType()
getMimeType | ( | Response | $response = null | ) |
◆ getCache()
|
protected |
- See also
- CacheTrait::getCache()
Definition at line 67 of file JsonFormat.php.
◆ getBaseCacheSection()
|
protected |
- See also
- CacheTrait::getBaseCacheSection()
Definition at line 74 of file JsonFormat.php.
◆ afterSerialize()
|
protected |
- See also
- AbstractFormat::afterSerialize()
Reimplemented from AbstractFormat.
Definition at line 81 of file JsonFormat.php.
◆ isSerializedNode()
|
protected |
Reimplemented from HierarchicalFormat.
Definition at line 107 of file JsonFormat.php.
◆ serializeNode()
|
protected |
Reimplemented from HierarchicalFormat.
Definition at line 114 of file JsonFormat.php.
◆ deserializeNode()
|
protected |
Reimplemented from HierarchicalFormat.
Definition at line 122 of file JsonFormat.php.
Member Data Documentation
◆ CACHE_SECTION
const CACHE_SECTION = 'jsonformat' |
Definition at line 37 of file JsonFormat.php.
◆ $cache
|
protected |
Definition at line 41 of file JsonFormat.php.
◆ $serializer
|
protected |
Definition at line 42 of file JsonFormat.php.