CoolCMS API

HydratorInterface

Shared contract of the read and extract hydrators used by the client (non-Api) save and read path; see {@see \App\Core\Traits\Shared\Models\Mappers\SaveTrait} and {@see \App\Core\Base\Front\Models\Mappers\ApiMapper}.

Two implementations with different metadata sources:

  • EntityHydrator: non-Api modules (Front/Admin/...); plain reflection and hydration attributes, never touches Doctrine.
  • OrmEntityHydrator: Api; Doctrine class metadata (persist through the ORM).

NOTE: autowiring in mappers and presenters targets the concrete class (two implementers make the interface ambiguous for DI); the interface only types the shared traits.

Table of Contents

Methods

applyIdentity()  : void
Writes the generated identity (id) back into the entity after a successful save.
extract()  : array<string, mixed>
Converts an object into a flat array (payload for Api writes; owned collections inline).
hydrate()  : object|null
Converts an array into an object; nested references resolve from the current cache.
hydrateAll()  : array{0: list, 1: int}
Converts an Api list response (`items` and `_references`) into a list of objects.
hydrateWithReferences()  : object|null
Converts an Api detail response (`data` and `_references`) into an object.

Methods

applyIdentity()

Writes the generated identity (id) back into the entity after a successful save.

public applyIdentity(object $entity, array<string|int, mixed> $data) : void
Parameters
$entity : object
$data : array<string|int, mixed>

extract()

Converts an object into a flat array (payload for Api writes; owned collections inline).

public extract(object $entity) : array<string, mixed>
Parameters
$entity : object
Return values
array<string, mixed>

hydrate()

Converts an array into an object; nested references resolve from the current cache.

public hydrate(array<string|int, mixed> $data, class-string $entityClass) : object|null
Parameters
$data : array<string|int, mixed>
$entityClass : class-string
Return values
object|null

hydrateAll()

Converts an Api list response (`items` and `_references`) into a list of objects.

public hydrateAll(array<string, mixed> $data, class-string $entityClass) : array{0: list, 1: int}
Parameters
$data : array<string, mixed>
$entityClass : class-string
Return values
array{0: list, 1: int} —

[items, totalCount]

hydrateWithReferences()

Converts an Api detail response (`data` and `_references`) into an object.

public hydrateWithReferences(array<string, mixed> $data, class-string $entityClass) : object|null
Parameters
$data : array<string, mixed>
$entityClass : class-string
Return values
object|null
On this page

Search results