PHP Class RESTfulAPI_EmberDataSerializer

. JSON serialization and de-serialization
Author: Thierry Francois @colymba [email protected]
Inheritance: extends RESTfulAPI_BasicSerializer
Afficher le fichier Open project: colymba/silverstripe-restfulapi

Protected Properties

Свойство Type Description
$sideloadedRecords array Stores the current $sideloaded_records config

Méthodes publiques

Méthode Description
__construct ( ) Construct and set current config
formatName ( string $name ) : string Format a SilverStripe ClassName or Field name to be used by the client API
serialize ( DataObject | DataList $data ) : string Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API

Méthodes protégées

Méthode Description
getSideloadData ( DataObject | DataList $dataSource ) : array Fetches and return all the data that need to be sideloaded for a specific source DataObject or DataList.
hasSideloadedRecords ( string $classname ) : boolean Check if a specific class requires data to be sideloaded.
insertSideloadData ( stdClass $root, DataObject | DataList $dataSource ) : stdClass 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 ( string $name ) : string Format a DB Column name or Field name to be used by the client API

Method Details

__construct() public méthode

Construct and set current config
public __construct ( )

formatName() public méthode

Format a SilverStripe ClassName or Field name to be used by the client API
public formatName ( string $name ) : string
$name string ClassName of DBField name
Résultat string Formatted name

getSideloadData() protected méthode

Fetches and return all the data that need to be sideloaded for a specific source DataObject or DataList.
protected getSideloadData ( DataObject | DataList $dataSource ) : array
$dataSource DataObject | DataList The source data to fetch sideloaded records for
Résultat array A map of relation names with their data

hasSideloadedRecords() protected méthode

Check if a specific class requires data to be sideloaded.
protected hasSideloadedRecords ( string $classname ) : boolean
$classname string Requested data classname
Résultat boolean True if some relations should be sideloaded

insertSideloadData() protected méthode

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.
protected insertSideloadData ( stdClass $root, DataObject | DataList $dataSource ) : stdClass
$root stdClass Root object ready to become JSON
$dataSource DataObject | DataList The original data set from the root object
Résultat stdClass The updated root object sith the sideloaded data attached

serialize() public méthode

Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API
public serialize ( DataObject | DataList $data ) : string
$data DataObject | DataList Data to serialize
Résultat string JSON representation of data

serializeColumnName() protected méthode

Format a DB Column name or Field name to be used by the client API
protected serializeColumnName ( string $name ) : string
$name string Field name
Résultat string Formatted name

Property Details

$sideloadedRecords protected_oe property

Stores the current $sideloaded_records config
protected array $sideloadedRecords
Résultat array