Skip to content

Instantly share code, notes, and snippets.

@imiroslavov
Last active March 2, 2020 14:37
Show Gist options
  • Save imiroslavov/86dc40205bc18f74c07b957d468e54c4 to your computer and use it in GitHub Desktop.
Save imiroslavov/86dc40205bc18f74c07b957d468e54c4 to your computer and use it in GitHub Desktop.
Custom doctrine hydrator
doctrine:
orm:
entity_managers:
default:
hydrators:
some_hydrator: App\Doctrine\ORM\Hydration\SomeHydrator
<?php
namespace App\Doctrine\ORM\Hydration;
use App\Entity\User;
use Doctrine\ORM\Internal\Hydration\ObjectHydrator;
class SomeHydrator extends ObjectHydrator
{
/**
* @return array
*/
protected function hydrateAllData()
{
$entries = parent::hydrateAllData();
$result = [];
foreach ($entries as $entry) {
...
// Do soemthing here
$result[] = ...
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment