Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down
Loading