/**
  * Transform object. Try create a object response via object in response.
  *
  * @param ActionViewEvent $event
  */
 public function transformObject(ActionViewEvent $event)
 {
     $data = $event->getData();
     if (is_array($data)) {
         $data = new \ArrayObject($data);
     }
     if ($this->normalizerManager->supports($data) && !$this->transformerManager->supports($data)) {
         $objectResponse = new ObjectTransformableResponse($data);
         $objectResponse->removeActionTransform();
         $response = $this->doTransformObjectResponse($objectResponse);
         $event->setResponse($response);
     }
     if ($this->transformerManager->supports($data)) {
         $objectResponse = new ObjectTransformableResponse($data);
         $response = $this->doTransformObjectResponse($objectResponse);
         $event->setResponse($response);
     }
 }
Exemple #2
0
 /**
  * On view event
  *
  * @param ActionViewEvent $event
  */
 public function onView(ActionViewEvent $event)
 {
     $message = sprintf('The action "%s" return not ResponseInterface instance. Try create Response instance via result data...', $event->getAction()->getName());
     $this->logger->debug($message);
 }