Skip to content

Commit

Permalink
Merge pull request #23 from wearemarketing/feature/solve-uow-issues
Browse files Browse the repository at this point in the history
change how AutoRoute entity is updated
  • Loading branch information
edgartebar authored Nov 5, 2019
2 parents d6e2e35 + c19dc87 commit ff1ea0f
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 ff1ea0f

Please sign in to comment.