Skip to content

Commit fdd88ef

Browse files
committed
Purge parent collections in inheritance cases
1 parent 47a6dff commit fdd88ef

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function onFlush(OnFlushEventArgs $eventArgs): void
8080

8181
foreach ($uow->getScheduledEntityInsertions() as $entity) {
8282
$this->gatherResourceAndItemTags($entity, false);
83+
$this->gatherParentResourceTags($em, $entity);
8384
$this->gatherRelationTags($em, $entity);
8485
}
8586

@@ -122,6 +123,25 @@ private function gatherResourceAndItemTags(object $entity, bool $purgeItem): voi
122123
}
123124
}
124125

126+
private function gatherParentResourceTags(EntityManagerInterface $em, object $entity): void
127+
{
128+
$classMetadata = $em->getClassMetadata($entity::class);
129+
130+
if ($classMetadata->isInheritanceTypeNone()) {
131+
return;
132+
}
133+
134+
foreach ($classMetadata->parentClasses as $parentClass) {
135+
if ($this->resourceClassResolver->isResourceClass($parentClass)) {
136+
try {
137+
$iri = $this->iriConverter->getIriFromResource($parentClass, UrlGeneratorInterface::ABS_PATH, new GetCollection());
138+
$this->tags[$iri] = $iri;
139+
} catch (OperationNotFoundException|InvalidArgumentException) {
140+
}
141+
}
142+
}
143+
}
144+
125145
private function gatherRelationTags(EntityManagerInterface $em, object $entity): void
126146
{
127147
$associationMappings = $em->getClassMetadata($entity::class)->getAssociationMappings();

0 commit comments

Comments
 (0)