// Optimize performance in case we have an object loader and
// a single-field identifier
if ($idReader &&
$this->objectLoader
) { $objects =
[];
$objectsById =
[];
// Maintain order and indices from the given $values
// An alternative approach to the following loop is to add the
// "INDEX BY" clause to the Doctrine query in the loader,
// but I'm not sure whether that's doable in a generic fashion.
foreach ($this->objectLoader->
getEntitiesByIds($idReader->
getIdField(),
$values) as $object) { $objectsById[$idReader->
getIdValue($object)] =
$object;
} foreach ($values as $i =>
$id) { if (isset($objectsById[$id])) { $objects[$i] =
$objectsById[$id];
} } return $objects;
}