Hydration
9 months ago
TopologicalSort
9 months ago
CriteriaOrderings.php
9 months ago
HydrationCompleteHandler.php
9 months ago
SQLResultCasing.php
9 months ago
StronglyConnectedComponents.php
9 months ago
TopologicalSort.php
9 months ago
index.php
9 months ago
HydrationCompleteHandler.php
38 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Internal; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\ORM\EntityManagerInterface; |
| 6 | use MailPoetVendor\Doctrine\ORM\Event\ListenersInvoker; |
| 7 | use MailPoetVendor\Doctrine\ORM\Event\PostLoadEventArgs; |
| 8 | use MailPoetVendor\Doctrine\ORM\Events; |
| 9 | use MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadata; |
| 10 | final class HydrationCompleteHandler |
| 11 | { |
| 12 | private $listenersInvoker; |
| 13 | private $em; |
| 14 | private $deferredPostLoadInvocations = []; |
| 15 | public function __construct(ListenersInvoker $listenersInvoker, EntityManagerInterface $em) |
| 16 | { |
| 17 | $this->listenersInvoker = $listenersInvoker; |
| 18 | $this->em = $em; |
| 19 | } |
| 20 | public function deferPostLoadInvoking(ClassMetadata $class, $entity) : void |
| 21 | { |
| 22 | $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postLoad); |
| 23 | if ($invoke === ListenersInvoker::INVOKE_NONE) { |
| 24 | return; |
| 25 | } |
| 26 | $this->deferredPostLoadInvocations[] = [$class, $invoke, $entity]; |
| 27 | } |
| 28 | public function hydrationComplete() : void |
| 29 | { |
| 30 | $toInvoke = $this->deferredPostLoadInvocations; |
| 31 | $this->deferredPostLoadInvocations = []; |
| 32 | foreach ($toInvoke as $classAndEntity) { |
| 33 | [$class, $invoke, $entity] = $classAndEntity; |
| 34 | $this->listenersInvoker->invoke($class, Events::postLoad, $entity, new PostLoadEventArgs($entity, $this->em), $invoke); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 |