Skip to content

Commit b62a2d0

Browse files
committed
Use ObjectManager in DoctrineResourceFlushTrait
1 parent 4447fd5 commit b62a2d0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/EventListener/Doctrine/DoctrineResourceFlushTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Doctrine\ORM\Event\PreUpdateEventArgs;
2626
use Doctrine\ORM\PersistentCollection;
2727
use Doctrine\Persistence\ManagerRegistry;
28+
use Doctrine\Persistence\ObjectManager;
2829
use Doctrine\Persistence\ObjectRepository;
2930
use Silverback\ApiComponentsBundle\Entity\Component\Collection;
3031
use Silverback\ApiComponentsBundle\Entity\Core\ComponentPosition;
@@ -58,7 +59,7 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void
5859
$this->collectUpdatedResource($object, 'updated');
5960

6061
$changeSet = $eventArgs->getEntityChangeSet();
61-
$associationMappings = $this->getAssociationMappings($eventArgs->getEntityManager(), $eventArgs->getObject());
62+
$associationMappings = $this->getAssociationMappings($eventArgs->getObjectManager(), $eventArgs->getObject());
6263

6364
if ($object instanceof PageDataInterface) {
6465
$this->pageDataPropertiesChanged = array_keys($changeSet);
@@ -99,7 +100,7 @@ public function postFlush(): void
99100
$this->purgeResources();
100101
}
101102

102-
private function gatherRelationResourceClasses(EntityManagerInterface $em, $entity): void
103+
private function gatherRelationResourceClasses(ObjectManager $em, $entity): void
103104
{
104105
$associationMappings = $this->getAssociationMappings($em, $entity);
105106
foreach (array_keys($associationMappings) as $property) {
@@ -155,12 +156,12 @@ private function gatherIrisForCollectionResources(): array
155156
return $collectionResources;
156157
}
157158

158-
private function getAssociationMappings(EntityManagerInterface $em, $entity): array
159+
private function getAssociationMappings(ObjectManager $em, $entity): array
159160
{
160161
return $em->getClassMetadata(ClassUtils::getClass($entity))->getAssociationMappings();
161162
}
162163

163-
private function collectUpdatedResource($resource, string $type, ?EntityManagerInterface $em = null, bool $gatherRelated = false): void
164+
private function collectUpdatedResource($resource, string $type, ?ObjectManager $em = null, bool $gatherRelated = false): void
164165
{
165166
if (!$resource) {
166167
return;

0 commit comments

Comments
 (0)