11
11
class Upload extends \Magento \Backend \App \Action
12
12
{
13
13
/**
14
- * @var \Magento\Framework\Controller\Result\JsonFactory
14
+ * @var \Magento\Framework\Controller\Result\RawFactory
15
15
*/
16
- protected $ resultJsonFactory ;
16
+ protected $ resultRawFactory ;
17
17
18
18
/**
19
19
* @param \Magento\Backend\App\Action\Context $context
20
- * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
20
+ * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
21
21
*/
22
22
public function __construct (
23
23
\Magento \Backend \App \Action \Context $ context ,
24
- \Magento \Framework \Controller \Result \JsonFactory $ resultJsonFactory
24
+ \Magento \Framework \Controller \Result \RawFactory $ resultRawFactory
25
25
) {
26
26
parent ::__construct ($ context );
27
- $ this ->resultJsonFactory = $ resultJsonFactory ;
27
+ $ this ->resultRawFactory = $ resultRawFactory ;
28
28
}
29
29
30
30
/**
@@ -36,7 +36,7 @@ protected function _isAllowed()
36
36
}
37
37
38
38
/**
39
- * @return \Magento\Framework\Controller\Result\Json
39
+ * @return \Magento\Framework\Controller\Result\Raw
40
40
*/
41
41
public function execute ()
42
42
{
@@ -72,6 +72,10 @@ public function execute()
72
72
$ result = ['error ' => $ e ->getMessage (), 'errorcode ' => $ e ->getCode ()];
73
73
}
74
74
75
- return $ this ->resultJsonFactory ->create ()->setData ($ result );
75
+ /** @var \Magento\Framework\Controller\Result\Raw $response */
76
+ $ response = $ this ->resultRawFactory ->create ();
77
+ $ response ->setHeader ('Content-type ' , 'text/plain ' );
78
+ $ response ->setContents (json_encode ($ result ));
79
+ return $ response ;
76
80
}
77
81
}
0 commit comments