diff --git a/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php b/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php index 8fdd0b3c96..286d7960f7 100644 --- a/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php +++ b/src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php @@ -80,6 +80,7 @@ public function onFlush(OnFlushEventArgs $eventArgs): void foreach ($uow->getScheduledEntityInsertions() as $entity) { $this->gatherResourceAndItemTags($entity, false); + $this->gatherParentResourceTags($em, $entity); $this->gatherRelationTags($em, $entity); } @@ -122,6 +123,25 @@ private function gatherResourceAndItemTags(object $entity, bool $purgeItem): voi } } + private function gatherParentResourceTags(EntityManagerInterface $em, object $entity): void + { + $classMetadata = $em->getClassMetadata($entity::class); + + if ($classMetadata->isInheritanceTypeNone()) { + return; + } + + foreach ($classMetadata->parentClasses as $parentClass) { + if ($this->resourceClassResolver->isResourceClass($parentClass)) { + try { + $iri = $this->iriConverter->getIriFromResource($parentClass, UrlGeneratorInterface::ABS_PATH, new GetCollection()); + $this->tags[$iri] = $iri; + } catch (OperationNotFoundException|InvalidArgumentException) { + } + } + } + } + private function gatherRelationTags(EntityManagerInterface $em, object $entity): void { $associationMappings = $em->getClassMetadata($entity::class)->getAssociationMappings();