Documentation

ArrayHydrator extends AbstractHydrator
in package

The ArrayHydrator produces a nested array "graph" that is often (not always) interchangeable with the corresponding object graph for read-only access.

Table of Contents

Properties

$_cache  : array<string, array<string|int, mixed>|null>
The cache used during row-by-row hydration.
$_em  : EntityManagerInterface
The EntityManager instance.
$_hints  : array<string, mixed>
The query hints.
$_metadataCache  : array<string, ClassMetadata<string|int, object>>
Local ClassMetadata cache to avoid going to the EntityManager all the time.
$_platform  : AbstractPlatform
The dbms Platform instance.
$_rsm  : ResultSetMapping|null
The ResultSetMapping.
$_stmt  : Result|null
The statement that provides the data to hydrate.
$_uow  : UnitOfWork
The UnitOfWork of the associated EntityManager.
$identifierMap  : array<string|int, mixed>
$idTemplate  : array<string, string>
$isSimpleQuery  : bool
$resultCounter  : int
$resultPointers  : array<string|int, mixed>
$rootAliases  : array<string, bool>

Methods

__construct()  : mixed
Initializes a new instance of a class derived from <tt>AbstractHydrator</tt>.
hydrateAll()  : array<string|int, mixed>
Hydrates all rows returned by the passed statement instance at once.
hydrateRow()  : array<string|int, mixed>|false
Hydrates a single row returned by the current statement instance during row-by-row hydration with {@link iterate()} or {@link toIterable()}.
iterate()  : IterableResult
Initiates a row-by-row hydration.
onClear()  : void
When executed in a hydrate() loop we have to clear internal state to decrease memory consumption.
toIterable()  : Generator<string|int, mixed>
Initiates a row-by-row hydration.
buildEnum()  : BackedEnum|array<string|int, BackedEnum>
cleanup()  : void
Executes one-time cleanup tasks at the end of a hydration that was initiated through {@link hydrateAll} or {@link iterate()}.
cleanupAfterRowIteration()  : void
gatherRowData()  : array<string, array<string, mixed>>
Processes a row of the result set.
gatherScalarRowData()  : array<string|int, mixed>
Processes a row of the result set.
getClassMetadata()  : ClassMetadata
Retrieve ClassMetadata associated to entity class name.
hydrateAllData()  : array<string|int, mixed>
Hydrates all rows from the current statement instance at once.
hydrateColumnInfo()  : array<string|int, mixed>|null
Retrieve column information from ResultSetMapping.
hydrateRowData()  : void
Hydrates a single row from the current statement instance.
prepare()  : void
Executes one-time preparation tasks, once each time hydration is started through {@link hydrateAll} or {@link iterate()}.
registerManaged()  : void
Register entity as managed in UnitOfWork.
resultSetMapping()  : ResultSetMapping
statement()  : Result
getDiscriminatorValues()  : array<string|int, string>
updateResultPointer()  : void
Updates the result pointer for an Entity. The result pointers point to the last seen instance of each Entity type. This is used for graph construction.

Properties

$_cache

The cache used during row-by-row hydration.

protected array<string, array<string|int, mixed>|null> $_cache = []

$_metadataCache

Local ClassMetadata cache to avoid going to the EntityManager all the time.

protected array<string, ClassMetadata<string|int, object>> $_metadataCache = []

$_stmt

The statement that provides the data to hydrate.

protected Result|null $_stmt

$identifierMap

private array<string|int, mixed> $identifierMap = []

$resultPointers

private array<string|int, mixed> $resultPointers = []

Methods

hydrateAll()

Hydrates all rows returned by the passed statement instance at once.

public hydrateAll(Result|ResultStatement $stmt, ResultSetMapping $resultSetMapping[, array<string|int, mixed> $hints = [] ]) : array<string|int, mixed>
Parameters
$stmt : Result|ResultStatement
$resultSetMapping : ResultSetMapping
$hints : array<string|int, mixed> = []
Tags
psalm-param

array<string, string> $hints

Return values
array<string|int, mixed>

hydrateRow()

Hydrates a single row returned by the current statement instance during row-by-row hydration with {@link iterate()} or {@link toIterable()}.

public hydrateRow() : array<string|int, mixed>|false
Tags
deprecated
Return values
array<string|int, mixed>|false

iterate()

Initiates a row-by-row hydration.

public iterate(Result|ResultStatement $stmt, ResultSetMapping $resultSetMapping[, array<string|int, mixed> $hints = [] ]) : IterableResult
Parameters
$stmt : Result|ResultStatement
$resultSetMapping : ResultSetMapping
$hints : array<string|int, mixed> = []
Tags
deprecated
psalm-param

array<string, mixed> $hints

Return values
IterableResult

onClear()

When executed in a hydrate() loop we have to clear internal state to decrease memory consumption.

public onClear(mixed $eventArgs) : void
Parameters
$eventArgs : mixed

toIterable()

Initiates a row-by-row hydration.

public toIterable(Result|ResultStatement $stmt, ResultSetMapping $resultSetMapping[, array<string|int, mixed> $hints = [] ]) : Generator<string|int, mixed>
Parameters
$stmt : Result|ResultStatement
$resultSetMapping : ResultSetMapping
$hints : array<string|int, mixed> = []
Tags
psalm-param

array<string, mixed> $hints

final
Return values
Generator<string|int, mixed>

buildEnum()

protected final buildEnum(mixed $value, BackedEnum> $enumType) : BackedEnum|array<string|int, BackedEnum>
Parameters
$value : mixed
$enumType : BackedEnum>
Return values
BackedEnum|array<string|int, BackedEnum>

cleanup()

Executes one-time cleanup tasks at the end of a hydration that was initiated through {@link hydrateAll} or {@link iterate()}.

protected cleanup() : void

gatherRowData()

Processes a row of the result set.

protected gatherRowData(array<string|int, mixed> $data, array<string|int, mixed> &$id, array<string|int, mixed> &$nonemptyComponents) : array<string, array<string, mixed>>

Used for identity-based hydration (HYDRATE_OBJECT and HYDRATE_ARRAY). Puts the elements of a result row into a new array, grouped by the dql alias they belong to. The column names in the result set are mapped to their field names during this procedure as well as any necessary conversions on the values applied. Scalar values are kept in a specific key 'scalars'.

Parameters
$data : array<string|int, mixed>

SQL Result Row.

$id : array<string|int, mixed>
$nonemptyComponents : array<string|int, mixed>
Tags
psalm-param

array<string, string> $id Dql-Alias => ID-Hash.

psalm-param

array<string, bool> $nonemptyComponents Does this DQL-Alias has at least one non NULL value?

psalm-return

array{ data: array<array-key, array>, newObjects?: array<array-key, array{ class: mixed, args?: array }>, scalars?: array }

Return values
array<string, array<string, mixed>>

An array with all the fields (name => value) of the data row, grouped by their component alias.

gatherScalarRowData()

Processes a row of the result set.

protected gatherScalarRowData(array<string|int, mixed> &$data) : array<string|int, mixed>

Used for HYDRATE_SCALAR. This is a variant of _gatherRowData() that simply converts column names to field names and properly converts the values according to their types. The resulting row has the same number of elements as before.

Parameters
$data : array<string|int, mixed>
Tags
psalm-param

array<string, mixed> $data

psalm-return

array<string, mixed>

Return values
array<string|int, mixed>

The processed row.

hydrateAllData()

Hydrates all rows from the current statement instance at once.

protected hydrateAllData() : array<string|int, mixed>
Return values
array<string|int, mixed>

hydrateColumnInfo()

Retrieve column information from ResultSetMapping.

protected hydrateColumnInfo(string $key) : array<string|int, mixed>|null
Parameters
$key : string

Column name

Tags
psalm-return

array<string, mixed>|null

Return values
array<string|int, mixed>|null

hydrateRowData()

Hydrates a single row from the current statement instance.

protected hydrateRowData(array<string|int, mixed> $row, array<string|int, mixed> &$result) : void
Parameters
$row : array<string|int, mixed>

The row data.

$result : array<string|int, mixed>

The result to fill.

prepare()

Executes one-time preparation tasks, once each time hydration is started through {@link hydrateAll} or {@link iterate()}.

protected prepare() : void

registerManaged()

Register entity as managed in UnitOfWork.

protected registerManaged(ClassMetadata $class, object $entity, array<string|int, mixed> $data) : void
Parameters
$class : ClassMetadata
$entity : object
$data : array<string|int, mixed>
Tags
todo

The "$id" generation is the same of UnitOfWork#createEntity. Remove this duplication somehow

getDiscriminatorValues()

private getDiscriminatorValues(ClassMetadata $classMetadata) : array<string|int, string>
Parameters
$classMetadata : ClassMetadata
Tags
psalm-return

non-empty-list

Return values
array<string|int, string>

updateResultPointer()

Updates the result pointer for an Entity. The result pointers point to the last seen instance of each Entity type. This is used for graph construction.

private updateResultPointer(array<string|int, mixed>|null &$coll, bool|int $index, string $dqlAlias, bool $oneToOne) : void
Parameters
$coll : array<string|int, mixed>|null

The element.

$index : bool|int

Index of the element in the collection.

$dqlAlias : string
$oneToOne : bool

Whether it is a single-valued association or not.


        
On this page

Search results