PHP Class Tobscure\JsonApi\Resource

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

Protected Properties

Property 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

Public Methods

Method 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 )

Protected Methods

Method 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 method

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

buildRelationships() protected method

Get an array of built relationships.
protected buildRelationships ( ) : Relationship[]
return Relationship[]

convertRelationshipsToArray() protected method

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

fields() public method

public fields ( $fields )

filterFields() protected method

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

getAttributes() public method

Get the resource attributes.
public getAttributes ( ) : array
return array

getData() public method

public getData ( ) : mixed
return mixed

getId() public method

Get the resource ID.
public getId ( ) : string
return string

getOwnFields() protected method

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

getRelationships() public method

Get the resource relationships.
public getRelationships ( ) : Relationship[]
return Relationship[]

getRelationshipsAsArray() public method

Get the resource relationships as an array.
public getRelationshipsAsArray ( ) : array
return array

getResources() public method

public getResources ( )

getSerializer() public method

public getSerializer ( ) : Tobscure\JsonApi\SerializerInterface
return Tobscure\JsonApi\SerializerInterface

getType() public method

Get the resource type.
public getType ( ) : string
return string

getUnfilteredRelationships() public method

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

isIdentifier() public method

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

merge() public method

Merge a resource into this one.
public merge ( Resource $resource ) : void
$resource Resource
return void

mergeAttributes() protected method

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

mergeRelationships() protected method

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

setData() public method

public setData ( mixed $data ) : void
$data mixed
return void

setSerializer() public method

public setSerializer ( Tobscure\JsonApi\SerializerInterface $serializer ) : void
$serializer Tobscure\JsonApi\SerializerInterface
return void

toArray() public method

public toArray ( )

toIdentifier() public method

public toIdentifier ( )

with() public method

public with ( $relationships )

Property Details

$data protected_oe property

protected mixed $data
return mixed

$fields protected_oe property

A list of fields to restrict to.
protected array|null $fields
return array | null

$includes protected_oe property

A list of relationships to include.
protected array $includes
return array

$merged protected_oe property

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

$serializer protected_oe property

protected SerializerInterface,Tobscure\JsonApi $serializer
return Tobscure\JsonApi\SerializerInterface