/** * @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event */ public function onKernelResultView(GetResponseForControllerResultEvent $event) { if (!$event->getRequest()->attributes->get('is_rest_request')) { return; } $event->setResponse($this->viewDispatcher->dispatch($event->getRequest(), $event->getControllerResult())); $event->stopPropagation(); }
/** * @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event * * @throws \Exception */ public function onKernelResultView(GetResponseForControllerResultEvent $event) { if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) { return; } if (!$this->isRestRequest($event->getRequest())) { return; } $result = $event->getControllerResult(); $event->setResponse($this->visitResult($result)); $event->stopPropagation(); }