PHP Trait WoohooLabs\Yin\JsonApi\Hydrator\HydratorTrait

Afficher le fichier Open project: woohoolabs/yin

Méthodes protégées

Méthode Description
doHydrateRelationship ( mixed $domainObject, string $relationshipName, callable $hydrator, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, array | null $relationshipData, array | null $data ) : mixed
getAcceptedType ( ) : string | array Determines which resource type or types can be accepted by the hydrator.
getArgumentTypeHintFromCallable ( callable $callable ) : string | null
getAttributeHydrator ( mixed $domainObject ) : callable[] Provides the attribute hydrators.
getRelationshipHydrator ( mixed $domainObject ) : callable[] Provides the relationship hydrators.
getRelationshipHydratorResult ( string $relationshipName, callable $hydrator, mixed $domainObject, ToOneRelationship | ToManyRelationship $relationshipObject, array | null $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
getRelationshipType ( object | string | null $object ) : string | null
hydrateAttributes ( mixed $domainObject, array $data ) : mixed
hydrateRelationships ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
validateType ( array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory )

Private Methods

Méthode Description
createRelationship ( array | null $relationship, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : ToOneRelationship
isAssociativeArray ( array $array ) : boolean

Method Details

doHydrateRelationship() protected méthode

protected doHydrateRelationship ( mixed $domainObject, string $relationshipName, callable $hydrator, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, array | null $relationshipData, array | null $data ) : mixed
$domainObject mixed
$relationshipName string
$hydrator callable
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
$relationshipData array | null
$data array | null
Résultat mixed

getAcceptedType() abstract protected méthode

If the hydrator can only accept one type of resources, the method should return a string. If it accepts more types, then it should return an array of strings. When such a resource is received for hydration which can't be accepted (its type doesn't match the acceptable type or types of the hydrator), a ResourceTypeUnacceptable exception will be raised.
abstract protected getAcceptedType ( ) : string | array
Résultat string | array

getArgumentTypeHintFromCallable() protected méthode

protected getArgumentTypeHintFromCallable ( callable $callable ) : string | null
$callable callable
Résultat string | null

getAttributeHydrator() abstract protected méthode

The method returns an array of attribute hydrators, where a hydrator is a key-value pair: the key is the specific attribute name which comes from the request and the value is a callable which hydrates the given attribute. These callables receive the domain object (which will be hydrated), the value of the currently processed attribute, the "data" part of the request and the name of the attribute to be hydrated as their arguments, and they should mutate the state of the domain object. If it is an immutable object or an array (and passing by reference isn't used), the callable should return the domain object.
abstract protected getAttributeHydrator ( mixed $domainObject ) : callable[]
$domainObject mixed
Résultat callable[]

getRelationshipHydrator() abstract protected méthode

The method returns an array of relationship hydrators, where a hydrator is a key-value pair: the key is the specific relationship name which comes from the request and the value is an callable which hydrate the previous relationship. These callables receive the domain object (which will be hydrated), an object representing the currently processed relationship (it can be a ToOneRelationship or a ToManyRelationship object), the "data" part of the request and the relationship name as their arguments, and they should mutate the state of the domain object. If it is an immutable object or an array (and passing by reference isn't used), the callable should return the domain object.
abstract protected getRelationshipHydrator ( mixed $domainObject ) : callable[]
$domainObject mixed
Résultat callable[]

getRelationshipHydratorResult() protected méthode

protected getRelationshipHydratorResult ( string $relationshipName, callable $hydrator, mixed $domainObject, ToOneRelationship | ToManyRelationship $relationshipObject, array | null $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
$relationshipName string
$hydrator callable
$domainObject mixed
$relationshipObject WoohooLabs\Yin\JsonApi\Hydrator\Relationship\ToOneRelationship | WoohooLabs\Yin\JsonApi\Hydrator\Relationship\ToManyRelationship
$data array | null
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
Résultat mixed

getRelationshipType() protected méthode

protected getRelationshipType ( object | string | null $object ) : string | null
$object object | string | null
Résultat string | null

hydrateAttributes() protected méthode

protected hydrateAttributes ( mixed $domainObject, array $data ) : mixed
$domainObject mixed
$data array
Résultat mixed

hydrateRelationships() protected méthode

protected hydrateRelationships ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
$domainObject mixed
$data array
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
Résultat mixed

validateType() protected méthode

protected validateType ( array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory )
$data array
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface