Last active
March 2, 2020 14:37
-
-
Save imiroslavov/86dc40205bc18f74c07b957d468e54c4 to your computer and use it in GitHub Desktop.
Custom doctrine hydrator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctrine: | |
orm: | |
entity_managers: | |
default: | |
hydrators: | |
some_hydrator: App\Doctrine\ORM\Hydration\SomeHydrator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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