PHP 클래스 RESTfulAPI_BasicSerializer

. JSON serialization and de-serialization
저자: Thierry Francois @colymba [email protected]
상속: implements RESTfulAPI_Serializer
파일 보기 프로젝트 열기: colymba/silverstripe-restfulapi 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$embeddedRecords array Stores the current $embedded_records @config Config set on {@link RESTfulAPI}

공개 메소드들

메소드 설명
__construct ( ) Construct and set current config
formatName ( string $name ) : string Format a SilverStripe ClassName or Field name to be used by the client API
getcontentType ( ) : string Return Content-type header definition to be used in the API response
serialize ( mixed $data ) : string Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API

보호된 메소드들

메소드 설명
formatDataList ( DataList $dataList ) : array Format a DataList into a formatted array ready to be turned into JSON
formatDataObject ( DataObject $dataObject ) : array | null Format a DataObject keys and values ready to be turned into JSON
getEmbedData ( DataObject $record, string $relationName ) : array | null Returns a DataObject relation's data formatted and ready to embed.
isEmbeddable ( string $model, string $relation ) : boolean Checks if a speicific model's relation should have its records embedded.
jsonify ( mixed $data ) : string Convert data into a JSON string
serializeColumnName ( string $name ) : string Format a DB Column name or Field name to be used by the client API

메소드 상세

__construct() 공개 메소드

Construct and set current config
public __construct ( )

formatDataList() 보호된 메소드

Format a DataList into a formatted array ready to be turned into JSON
protected formatDataList ( DataList $dataList ) : array
$dataList DataList The DataList to format
리턴 array The formatted array representation of the DataList

formatDataObject() 보호된 메소드

Format a DataObject keys and values ready to be turned into JSON
protected formatDataObject ( DataObject $dataObject ) : array | null
$dataObject DataObject The data object to format
리턴 array | null The formatted array map representation of the DataObject or null is permission denied

formatName() 공개 메소드

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
리턴 string Formatted name

getEmbedData() 보호된 메소드

Returns a DataObject relation's data formatted and ready to embed.
protected getEmbedData ( DataObject $record, string $relationName ) : array | null
$record DataObject The DataObject to get the data from
$relationName string The name of the relation
리턴 array | null Formatted DataObject or RelationList ready to embed or null if nothing to embed

getcontentType() 공개 메소드

Return Content-type header definition to be used in the API response
public getcontentType ( ) : string
리턴 string Content-type

isEmbeddable() 보호된 메소드

Checks if a speicific model's relation should have its records embedded.
protected isEmbeddable ( string $model, string $relation ) : boolean
$model string Model's classname
$relation string Relation name
리턴 boolean Trus if the relation should be embedded

jsonify() 보호된 메소드

Convert data into a JSON string
protected jsonify ( mixed $data ) : string
$data mixed Data to convert
리턴 string JSON data

serialize() 공개 메소드

Convert raw data (DataObject or DataList) to JSON ready to be consumed by the client API
public serialize ( mixed $data ) : string
$data mixed Data to serialize
리턴 string JSON representation of data

serializeColumnName() 보호된 메소드

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

프로퍼티 상세

$embeddedRecords 보호되어 있는 프로퍼티

Stores the current $embedded_records @config Config set on {@link RESTfulAPI}
protected array $embeddedRecords
리턴 array