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.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 34 of file JsonFormat.php.

+ Inheritance diagram for JsonFormat:

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
$serializerNodeSerializer instance
$dynamicCacheCache instance

Definition at line 49 of file JsonFormat.php.

Member Function Documentation

◆ getMimeType()

getMimeType ( Response  $response = null)
See also
Format::getMimeType()

Implements Format.

Definition at line 60 of file JsonFormat.php.

◆ getCache()

getCache ( )
protected
See also
CacheTrait::getCache()

Definition at line 67 of file JsonFormat.php.

◆ getBaseCacheSection()

getBaseCacheSection ( )
protected
See also
CacheTrait::getBaseCacheSection()

Definition at line 74 of file JsonFormat.php.

◆ afterSerialize()

afterSerialize ( Response  $response)
protected
See also
AbstractFormat::afterSerialize()

Reimplemented from AbstractFormat.

Definition at line 81 of file JsonFormat.php.

◆ isSerializedNode()

isSerializedNode (   $value)
protected
See also
HierarchicalFormat::isSerializedNode()

Reimplemented from HierarchicalFormat.

Definition at line 107 of file JsonFormat.php.

◆ serializeNode()

serializeNode (   $value)
protected
See also
HierarchicalFormat::serializeNode()

Reimplemented from HierarchicalFormat.

Definition at line 114 of file JsonFormat.php.

◆ deserializeNode()

deserializeNode (   $value)
protected
See also
HierarchicalFormat::deserializeNode()

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

$cache = null
protected

Definition at line 41 of file JsonFormat.php.

◆ $serializer

$serializer = null
protected

Definition at line 42 of file JsonFormat.php.