Skip to content

Commit 9cd597f

Browse files
wtfzdotnetsoyuka
andauthored
fix(doctrine): remove usage of deprecated ClassUtils in PurgeHttpCacheListener for Doctrine ORM 3 (#6331)
Co-authored-by: Antoine Bluchet <[email protected]>
1 parent c083af3 commit 9cd597f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Doctrine/EventListener/PurgeHttpCacheListener.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use ApiPlatform\Metadata\ResourceClassResolverInterface;
2525
use ApiPlatform\Metadata\UrlGeneratorInterface;
2626
use ApiPlatform\Metadata\Util\ClassInfoTrait;
27-
use Doctrine\Common\Util\ClassUtils;
2827
use Doctrine\ORM\EntityManagerInterface;
2928
use Doctrine\ORM\Event\OnFlushEventArgs;
3029
use Doctrine\ORM\Event\PreUpdateEventArgs;
@@ -60,7 +59,7 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void
6059
$changeSet = $eventArgs->getEntityChangeSet();
6160
// @phpstan-ignore-next-line
6261
$objectManager = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
63-
$associationMappings = $objectManager->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();
62+
$associationMappings = $objectManager->getClassMetadata(\get_class($eventArgs->getObject()))->getAssociationMappings();
6463

6564
foreach ($changeSet as $key => $value) {
6665
if (!isset($associationMappings[$key])) {
@@ -127,7 +126,7 @@ private function gatherResourceAndItemTags(object $entity, bool $purgeItem): voi
127126

128127
private function gatherRelationTags(EntityManagerInterface $em, object $entity): void
129128
{
130-
$associationMappings = $em->getClassMetadata(ClassUtils::getClass($entity))->getAssociationMappings();
129+
$associationMappings = $em->getClassMetadata($entity::class)->getAssociationMappings();
131130
/** @var array|AssociationMapping $associationMapping according to the version of doctrine orm */
132131
foreach ($associationMappings as $property => $associationMapping) {
133132
if ($associationMapping instanceof AssociationMapping && ($associationMapping->targetEntity ?? null) && !$this->resourceClassResolver->isResourceClass($associationMapping->targetEntity)) {

0 commit comments

Comments
 (0)