getControllerResult(); if ($result instanceof TestDomainObject) { if ($result instanceof AttachmentsTestDomainObject) { $event->setResponse(new AttachmentsTestResponse('AttachmentsTestDomainObject')); } elseif ($result instanceof CacheableTestDomainObject) { $event->setResponse(new CacheableTestResponse('CacheableTestDomainObject')); } else { $event->setResponse(new Response('TestDomainObject')); } } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { $events[KernelEvents::VIEW][] = ['onViewTestDomainObject']; return $events; } }