diff --git a/src/Doctrine/Orm/AutoRouteListener.php b/src/Doctrine/Orm/AutoRouteListener.php index 352d0c3..8a9f90b 100644 --- a/src/Doctrine/Orm/AutoRouteListener.php +++ b/src/Doctrine/Orm/AutoRouteListener.php @@ -89,7 +89,9 @@ private function parseUpdateEntities(array $inEntities) private function isAutoRouteable($document) { try { - return (boolean)$this->getMetadataFactory()->getMetadataForClass(get_class($document)); + $metadataFactory = $this->getMetadataFactory(); + $classMetadata = $metadataFactory->getMetadataForClass(get_class($document)); + return (boolean)$classMetadata; } catch (ClassNotMappedException $e) { return false; } @@ -140,9 +142,15 @@ public function onFlush(OnFlushEventArgs $eventArgs) //set persistence order to allow set in the route the contentEntity PK if ($new) { + + $fromHash = $this->getEntityMetadata($manager, $entity)->name; + + $commitOrderCalculator->addNode($fromHash, $entity); + $commitOrderCalculator->addDependency( - $this->getEntityMetadata($manager, $entity), - $this->getEntityMetadata($manager, $autoRoute) + $fromHash, + $this->getEntityMetadata($manager, $autoRoute)->name, + 1 ); } @@ -189,7 +197,8 @@ public function postPersist(LifecycleEventArgs $eventArgs) $autoRoute->setContentId($id); $this->replaceIdOnNameField($autoRoute, $id, 'name'); $this->replaceIdOnNameField($autoRoute, $id, 'canonicalName'); - $unitOfWork->recomputeSingleEntityChangeSet($this->getEntityMetadata($manager, $autoRoute), $autoRoute); + + $unitOfWork->computeChangeSet($this->getEntityMetadata($manager, $autoRoute), $autoRoute); } } }