Skip to content

Commit

Permalink
change how AutoRoute entity is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Tebar committed Nov 5, 2019
1 parent d6e2e35 commit c19dc87
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Doctrine/Orm/AutoRouteListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
);
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit c19dc87

Please sign in to comment.