コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * @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();
 }