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
= []
$_em
The EntityManager instance.
protected
EntityManagerInterface
$_em
$_hints
The query hints.
protected
array<string, mixed>
$_hints
= []
$_metadataCache
Local ClassMetadata cache to avoid going to the EntityManager all the time.
protected
array<string, ClassMetadata<string|int, object>>
$_metadataCache
= []
$_platform
The dbms Platform instance.
protected
AbstractPlatform
$_platform
$_rsm
The ResultSetMapping.
protected
ResultSetMapping|null
$_rsm
$_stmt
The statement that provides the data to hydrate.
protected
Result|null
$_stmt
$_uow
The UnitOfWork of the associated EntityManager.
protected
UnitOfWork
$_uow
$identifierMap
private
array<string|int, mixed>
$identifierMap
= []
$idTemplate
private
array<string, string>
$idTemplate
= []
$isSimpleQuery
private
bool
$isSimpleQuery
= false
$resultCounter
private
int
$resultCounter
= 0
$resultPointers
private
array<string|int, mixed>
$resultPointers
= []
$rootAliases
private
array<string, bool>
$rootAliases
= []
Methods
__construct()
Initializes a new instance of a class derived from <tt>AbstractHydrator</tt>.
public
__construct(EntityManagerInterface $em) : mixed
Parameters
- $em : EntityManagerInterface
-
The EntityManager to use.
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
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
Return values
array<string|int, mixed>|falseiterate()
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
Return values
IterableResultonClear()
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
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
cleanupAfterRowIteration()
protected
cleanupAfterRowIteration() : 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
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
Return values
array<string|int, mixed> —The processed row.
getClassMetadata()
Retrieve ClassMetadata associated to entity class name.
protected
getClassMetadata(string $className) : ClassMetadata
Parameters
- $className : string
Return values
ClassMetadatahydrateAllData()
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
Return values
array<string|int, mixed>|nullhydrateRowData()
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
resultSetMapping()
protected
final resultSetMapping() : ResultSetMapping
Return values
ResultSetMappingstatement()
protected
final statement() : Result
Return values
ResultgetDiscriminatorValues()
private
getDiscriminatorValues(ClassMetadata $classMetadata) : array<string|int, string>
Parameters
- $classMetadata : ClassMetadata
Tags
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.