PHP Trait WoohooLabs\Yin\JsonApi\Hydrator\UpdateHydratorTrait

Mostrar archivo Open project: woohoolabs/yin

Public Methods

Method Description
hydrateForRelationshipUpdate ( string $relationship, WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, mixed $domainObject ) : mixed
hydrateForUpdate ( WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, mixed $domainObject ) : mixed Hydrates the domain object from the updating request.

Protected Methods

Method Description
doHydrateRelationship ( mixed $domainObject, string $relationshipName, callable $hydrator, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, array | null $relationshipData, array | null $data ) : mixed
getRelationshipHydrator ( mixed $domainObject ) : callable[] Provides the relationship hydrators.
hydrateAttributes ( mixed $domainObject, array $data ) : mixed
hydrateIdForUpdate ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
hydrateRelationships ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
setId ( mixed $domainObject, string $id ) : mixed | null Sets the given ID for the domain object.
validateType ( array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory )

Method Details

doHydrateRelationship() abstract protected method

abstract 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
return mixed

getRelationshipHydrator() abstract protected method

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
return callable[]

hydrateAttributes() abstract protected method

abstract protected hydrateAttributes ( mixed $domainObject, array $data ) : mixed
$domainObject mixed
$data array
return mixed

hydrateForRelationshipUpdate() public method

public hydrateForRelationshipUpdate ( string $relationship, WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, mixed $domainObject ) : mixed
$relationship string
$request WoohooLabs\Yin\JsonApi\Request\RequestInterface
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
$domainObject mixed
return mixed

hydrateForUpdate() public method

The domain object's attributes and relationships are hydrated according to the JSON API specification.
public hydrateForUpdate ( WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, mixed $domainObject ) : mixed
$request WoohooLabs\Yin\JsonApi\Request\RequestInterface
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
$domainObject mixed
return mixed

hydrateIdForUpdate() protected method

protected hydrateIdForUpdate ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
$domainObject mixed
$data array
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
return mixed

hydrateRelationships() abstract protected method

abstract protected hydrateRelationships ( mixed $domainObject, array $data, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory ) : mixed
$domainObject mixed
$data array
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
return mixed

setId() abstract protected method

The method mutates the domain object and sets the given ID for it. If it is an immutable object or an array the whole, updated domain object can be returned.
abstract protected setId ( mixed $domainObject, string $id ) : mixed | null
$domainObject mixed
$id string
return mixed | null

validateType() abstract protected method

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