PHP Interface WoohooLabs\Yin\JsonApi\Transformer\ResourceTransformerInterface

Mostra file Open project: woohoolabs/yin Interface Usage Examples

Public Methods

Method Description
getAttributes ( mixed $domainObject ) : callable[] Provides information about the "attributes" section of the current resource.
getDefaultIncludedRelationships ( mixed $domainObject ) : array Returns an array of relationship names which are included in the response by default.
getId ( mixed $domainObject ) : string Provides information about the "id" section of the current resource.
getLinks ( mixed $domainObject ) : WoohooLabs\Yin\JsonApi\Schema\Links | null Provides information about the "links" section of the current resource.
getMeta ( mixed $domainObject ) : array Provides information about the "meta" section of the current resource.
getRelationships ( mixed $domainObject ) : callable[] Provides information about the "relationships" section of the current resource.
getType ( mixed $domainObject ) : string Provides information about the "type" section of the current resource.
transformRelationship ( string $relationshipName, Transformation $transformation, mixed $domainObject, array $additionalMeta = [] ) : array
transformToResource ( Transformation $transformation, mixed $domainObject ) : array
transformToResourceIdentifier ( mixed $domainObject ) : array | null

Method Details

getAttributes() public method

The method returns an array where the keys signify the attribute names, while the values are callables receiving the domain object as an argument, and they should return the value of the corresponding attribute.
public getAttributes ( mixed $domainObject ) : callable[]
$domainObject mixed
return callable[]

getDefaultIncludedRelationships() public method

Returns an array of relationship names which are included in the response by default.
public getDefaultIncludedRelationships ( mixed $domainObject ) : array
$domainObject mixed
return array

getId() public method

The method returns the ID of the current resource which should be a UUID.
public getId ( mixed $domainObject ) : string
$domainObject mixed
return string

getMeta() public method

The method returns an array of non-standard meta information about the resource. If this array is empty, the section won't appear in the response.
public getMeta ( mixed $domainObject ) : array
$domainObject mixed
return array

getRelationships() public method

The method returns an array where the keys signify the relationship names, while the values are callables receiving the domain object as an argument, and they should return a new relationship instance (to-one or to-many).
public getRelationships ( mixed $domainObject ) : callable[]
$domainObject mixed
return callable[]

getType() public method

The method returns the type of the current resource.
public getType ( mixed $domainObject ) : string
$domainObject mixed
return string

transformRelationship() public method

public transformRelationship ( string $relationshipName, Transformation $transformation, mixed $domainObject, array $additionalMeta = [] ) : array
$relationshipName string
$transformation Transformation
$domainObject mixed
$additionalMeta array
return array

transformToResource() public method

public transformToResource ( Transformation $transformation, mixed $domainObject ) : array
$transformation Transformation
$domainObject mixed
return array

transformToResourceIdentifier() public method

public transformToResourceIdentifier ( mixed $domainObject ) : array | null
$domainObject mixed
return array | null