Esempio n. 1
0
 /**
  * {@inheritdoc}
  *
  * @todo: It seems that we need to implement a view handler for FOS Rest Bundle
  * @todo: https://magecore.atlassian.net/browse/BAP-8351
  */
 protected function buildResponse($data, $action, $contextValues = [], $status = Codes::HTTP_OK)
 {
     if ($status === Codes::HTTP_OK) {
         $format = $this->getRequest()->getRequestFormat();
         if ($format === 'binary') {
             if ($action !== self::ACTION_READ) {
                 throw new BadRequestHttpException('Only single file can be returned in the binary format');
             }
             return $this->getBinaryResponse($data, $action, $contextValues, $status);
         } else {
             if ($data instanceof View) {
                 $data->setData($this->postProcessResponseData($data->getData(), $action, $format));
             } elseif (!empty($data)) {
                 $data = $this->postProcessResponseData($data, $action, $format);
             }
             return parent::buildResponse($data, $action, $contextValues, $status);
         }
     } else {
         return parent::buildResponse($data, $action, $contextValues, $status);
     }
 }