diff --git a/src/EventListener/WriteListener.php b/src/EventListener/WriteListener.php index 26ae4829baa..6cbdfc3f717 100644 --- a/src/EventListener/WriteListener.php +++ b/src/EventListener/WriteListener.php @@ -90,7 +90,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event): void $hasOutput = \array_key_exists('class', $outputMetadata) && null !== $outputMetadata['class'] && $controllerResult instanceof $outputMetadata['class']; } - if ($hasOutput) { + if ($hasOutput && is_subclass_of($controllerResult, $attributes['resource_class'], true)) { $request->attributes->set('_api_write_item_iri', $this->iriConverter->getIriFromItem($controllerResult)); } break;