Skip to content

Instantly share code, notes, and snippets.

@ryanotella
Created April 30, 2015 05:17
Show Gist options
  • Save ryanotella/acdd548aba2b4aedd2b4 to your computer and use it in GitHub Desktop.
Save ryanotella/acdd548aba2b4aedd2b4 to your computer and use it in GitHub Desktop.
Hydrate all entities in the system
<?php
$doctrine = ...;
foreach ($entities as $entity) {
$metadata = $doctrine->getEntityManager()->getClassMetadata($entity);
$query = $doctrine->getEntityManager()->getRepository($entity)->createQueryBuilder('o');
foreach ($metadata->getAssociationMappings() as $association) {
$query->setFetchMode($entity, $association, 'EAGER');
}
try {
foreach ($query->getIterator() as $result) {
print '.';
}
} catch (\Exception $e) {
var_dump($e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment