\RESTfulAPI_EmberDataSerializer
EmberData RESTfulAPI Model Serializer handles DataObject, DataList etc.. JSON serialization and de-serialization
- Author: Thierry Francois @colymba thierry@colymba.com
- Copyright: Copyright (c) 2013, Thierry Francois
- License: http://opensource.org/licenses/BSD-3-Clause BSD Simplified
Synopsis
class RESTfulAPI_EmberDataSerializer
extends RESTfulAPI_BasicSerializer
{
- // members
- private string $contentType = 'application/vnd.api+json; charset=utf-8';
- private static $sideloaded_records;
- protected $sideloadedRecords;
- // Inherited members from RESTfulAPI_BasicSerializer
- protected $embeddedRecords;
- // methods
- public void __construct()
- public string serialize()
- public string formatName()
- protected string serializeColumnName()
- protected boolean hasSideloadedRecords()
- protected array getSideloadData()
- protected stdClass insertSideloadData()
- // Inherited methods from RESTfulAPI_BasicSerializer
- public string getcontentType()
- public void __construct()
- protected string jsonify()
- public string serialize()
- protected array|null formatDataObject()
- protected array formatDataList()
- public string formatName()
- protected string serializeColumnName()
- protected array|null getEmbedData()
- protected boolean isEmbeddable()
Hierarchy
Extends
Members
private
- $contentType
—
string
Content-type header definition for this Serializer Used by RESTfulAPI in the response - $sideloaded_records
—
array
Sideloaded records settings Specify which relation's records will be added to the JSON root: 'RequestedClass' => array('RelationNameToSideLoad', 'Another')
protected
- $embeddedRecords
—
array
Stores the current $embedded_records @config Config set on {@link RESTfulAPI} - $sideloadedRecords
—
array
Stores the current $sideloaded_records config
Methods
protected
- getSideloadData() — Fetches and return all the data that need to be sideloaded for a specific source DataObject or DataList.
- hasSideloadedRecords() — Check if a specific class requires data to be sideloaded.
- insertSideloadData() — Take a root object ready to be converted into JSON and an original data source (DataObject OR DataList) and insorts into the root object all relation records that should be sideloaded.
- serializeColumnName() — Format a DB Column name or Field name to be used by the client API
public
- __construct() — Construct and set current config
- formatName() — Format a SilverStripe ClassName or Field name to be used by the client API
- serialize() — Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API
Inherited from RESTfulAPI_BasicSerializer
protected
- formatDataList() — Format a DataList into a formatted array ready to be turned into JSON
- formatDataObject() — Format a DataObject keys and values ready to be turned into JSON
- getEmbedData() — Returns a DataObject relation's data formatted and ready to embed.
- isEmbeddable() — Checks if a speicific model's relation should have its records embedded.
- jsonify() — Convert data into a JSON string
- serializeColumnName() — Format a DB Column name or Field name to be used by the client API
public
- formatName() — Format a SilverStripe ClassName or Field name to be used by the client API
- getcontentType() — Return Content-type header definition to be used in the API response
- serialize() — Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API