diff -Nuar a/vendor/magento/module-banner/Controller/Ajax/Load.php b/vendor/magento/module-banner/Controller/Ajax/Load.php index bb88e6164ae..01e8c71a23f 100644 --- a/vendor/magento/module-banner/Controller/Ajax/Load.php +++ b/vendor/magento/module-banner/Controller/Ajax/Load.php @@ -5,12 +5,14 @@ */ namespace Magento\Banner\Controller\Ajax; -use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; use Magento\Backend\App\Action\Context; use Magento\Banner\Model\Banner\DataFactory; use Magento\Framework\App\Action\Action; +use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\Controller\Result\RawFactory; +use Zend\Http\AbstractMessage; +use Zend\Http\Response; /** * Banner loading @@ -51,20 +53,22 @@ class Load extends Action implements HttpGetActionInterface } /** - * {@inheritdoc} + * @inheritdoc */ public function execute() { - $resultRaw = $this->rawFactory->create(); $dataObject = $this->dataFactory->create(); - + $resultJson = $this->jsonFactory->create(); if (!$this->getRequest()->isXmlHttpRequest()) { - return $resultRaw->setHttpResponseCode(400); + $resultJson->setStatusHeader( + Response::STATUS_CODE_400, + AbstractMessage::VERSION_11, + 'Invalid Request' + ); + $response = ['message' => __('Invalid Request')]; + } else { + $response = ['data' => $dataObject->getSectionData()]; } - - $response = ['data' => $dataObject->getSectionData()]; - $resultJson = $this->jsonFactory->create(); - return $resultJson->setData($response); } }