PHP Class Tobscure\JsonApi\Resource

Inheritance: implements Tobscure\JsonApi\ElementInterface, use trait LinksTrait, use trait MetaTrait
Afficher le fichier Open project: tobscure/json-api Class Usage Examples

Protected Properties

Свойство Type Description
$data mixed
$fields array | null A list of fields to restrict to.
$includes array A list of relationships to include.
$merged Resource[] An array of Resources that should be merged into this one.
$serializer Tobscure\JsonApi\SerializerInterface

Méthodes publiques

Méthode Description
__construct ( mixed $data, Tobscure\JsonApi\SerializerInterface $serializer )
fields ( $fields )
getAttributes ( ) : array Get the resource attributes.
getData ( ) : mixed
getId ( ) : string Get the resource ID.
getRelationships ( ) : Relationship[] Get the resource relationships.
getRelationshipsAsArray ( ) : array Get the resource relationships as an array.
getResources ( )
getSerializer ( ) : Tobscure\JsonApi\SerializerInterface
getType ( ) : string Get the resource type.
getUnfilteredRelationships ( ) : Relationship[] Get the resource relationships without considering requested ones.
isIdentifier ( ) : boolean Check whether or not this resource is an identifier (i.e. does it have any data attached?).
merge ( Resource $resource ) : void Merge a resource into this one.
setData ( mixed $data ) : void
setSerializer ( Tobscure\JsonApi\SerializerInterface $serializer ) : void
toArray ( )
toIdentifier ( )
with ( $relationships )

Méthodes protégées

Méthode Description
buildRelationships ( ) : Relationship[] Get an array of built relationships.
convertRelationshipsToArray ( array $relationships ) : array Convert the given array of Relationship objects into an array.
filterFields ( array $fields ) : array Filter the given fields array (attributes or relationships) according to the requested fieldset.
getOwnFields ( ) : array | null Get the requested fields for this resource type.
mergeAttributes ( array $attributes ) : array Merge the attributes of merged resources into an array of attributes.
mergeRelationships ( array $relationships ) : array Merge the relationships of merged resources into an array of relationships.

Method Details

__construct() public méthode

public __construct ( mixed $data, Tobscure\JsonApi\SerializerInterface $serializer )
$data mixed
$serializer Tobscure\JsonApi\SerializerInterface

buildRelationships() protected méthode

Get an array of built relationships.
protected buildRelationships ( ) : Relationship[]
Résultat Relationship[]

convertRelationshipsToArray() protected méthode

Convert the given array of Relationship objects into an array.
protected convertRelationshipsToArray ( array $relationships ) : array
$relationships array
Résultat array

fields() public méthode

public fields ( $fields )

filterFields() protected méthode

Filter the given fields array (attributes or relationships) according to the requested fieldset.
protected filterFields ( array $fields ) : array
$fields array
Résultat array

getAttributes() public méthode

Get the resource attributes.
public getAttributes ( ) : array
Résultat array

getData() public méthode

public getData ( ) : mixed
Résultat mixed

getId() public méthode

Get the resource ID.
public getId ( ) : string
Résultat string

getOwnFields() protected méthode

Get the requested fields for this resource type.
protected getOwnFields ( ) : array | null
Résultat array | null

getRelationships() public méthode

Get the resource relationships.
public getRelationships ( ) : Relationship[]
Résultat Relationship[]

getRelationshipsAsArray() public méthode

Get the resource relationships as an array.
public getRelationshipsAsArray ( ) : array
Résultat array

getResources() public méthode

public getResources ( )

getSerializer() public méthode

public getSerializer ( ) : Tobscure\JsonApi\SerializerInterface
Résultat Tobscure\JsonApi\SerializerInterface

getType() public méthode

Get the resource type.
public getType ( ) : string
Résultat string

getUnfilteredRelationships() public méthode

Get the resource relationships without considering requested ones.
public getUnfilteredRelationships ( ) : Relationship[]
Résultat Relationship[]

isIdentifier() public méthode

Check whether or not this resource is an identifier (i.e. does it have any data attached?).
public isIdentifier ( ) : boolean
Résultat boolean

merge() public méthode

Merge a resource into this one.
public merge ( Resource $resource ) : void
$resource Resource
Résultat void

mergeAttributes() protected méthode

Merge the attributes of merged resources into an array of attributes.
protected mergeAttributes ( array $attributes ) : array
$attributes array
Résultat array

mergeRelationships() protected méthode

Merge the relationships of merged resources into an array of relationships.
protected mergeRelationships ( array $relationships ) : array
$relationships array
Résultat array

setData() public méthode

public setData ( mixed $data ) : void
$data mixed
Résultat void

setSerializer() public méthode

public setSerializer ( Tobscure\JsonApi\SerializerInterface $serializer ) : void
$serializer Tobscure\JsonApi\SerializerInterface
Résultat void

toArray() public méthode

public toArray ( )

toIdentifier() public méthode

public toIdentifier ( )

with() public méthode

public with ( $relationships )

Property Details

$data protected_oe property

protected mixed $data
Résultat mixed

$fields protected_oe property

A list of fields to restrict to.
protected array|null $fields
Résultat array | null

$includes protected_oe property

A list of relationships to include.
protected array $includes
Résultat array

$merged protected_oe property

An array of Resources that should be merged into this one.
protected Resource[],Tobscure\JsonApi $merged
Résultat Resource[]

$serializer protected_oe property

protected SerializerInterface,Tobscure\JsonApi $serializer
Résultat Tobscure\JsonApi\SerializerInterface