Class LazyEagerLoader
Contains methods that are capable of injecting eagerly loaded associations into entities or lists of entities by using the same syntax as the EagerLoader.
Method Summary
-
_getPropertyMap() protected
Returns a map of property names where the association results should be injected in the top level entities.
-
_getQuery() protected
Builds a query for loading the passed list of entity objects along with the associations specified in $contain.
-
_injectResults() protected
Injects the results of the eager loader query into the original list of entities.
-
loadInto() public
Loads the specified associations in the passed entity or list of entities by executing extra queries in the database and merging the results in the appropriate properties.
Method Detail
_getPropertyMap() ¶ protected
_getPropertyMap(Cake\ORM\Table $source, list<string> $associations): array<string, string>
Returns a map of property names where the association results should be injected in the top level entities.
Parameters
-
Cake\ORM\Table
$source The table having the top level associations
-
list<string>
$associations The name of the top level associations
Returns
array<string, string>
_getQuery() ¶ protected
_getQuery(arrayCake\Datasource\EntityInterface> $entities, array $contain, Cake\ORM\Table $source): Cake\ORM\Query\SelectQuery
Builds a query for loading the passed list of entity objects along with the associations specified in $contain.
Parameters
-
arrayCake\Datasource\EntityInterface>
$entities The original entities
-
array
$contain The associations to be loaded
-
Cake\ORM\Table
$source The table to use for fetching the top level entities
Returns
Cake\ORM\Query\SelectQuery
_injectResults() ¶ protected
_injectResults(arrayCake\Datasource\EntityInterface> $entities, Cake\ORM\Query\SelectQuery $query, list<string> $associations, Cake\ORM\Table $source): arrayCake\Datasource\EntityInterface>
Injects the results of the eager loader query into the original list of entities.
Parameters
-
arrayCake\Datasource\EntityInterface>
$entities The original list of entities
-
Cake\ORM\Query\SelectQuery
$query The query to load results
-
list<string>
$associations The top level associations that were loaded
-
Cake\ORM\Table
$source The table where the entities came from
Returns
arrayCake\Datasource\EntityInterface>
loadInto() ¶ public
loadInto(Cake\Datasource\EntityInterface|arrayCake\Datasource\EntityInterface> $entities, array $contain, Cake\ORM\Table $source): Cake\Datasource\EntityInterface|arrayCake\Datasource\EntityInterface>
Loads the specified associations in the passed entity or list of entities by executing extra queries in the database and merging the results in the appropriate properties.
The properties for the associations to be loaded will be overwritten on each entity.
Parameters
-
Cake\Datasource\EntityInterface|arrayCake\Datasource\EntityInterface>
$entities a single entity or list of entities
-
array
$contain A
contain()
compatible array.-
Cake\ORM\Table
$source The table to use for fetching the top level entities
Returns
Cake\Datasource\EntityInterface|arrayCake\Datasource\EntityInterface>