|
20 | 20 | */
|
21 | 21 | class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index
|
22 | 22 | {
|
| 23 | + /** |
| 24 | + * @var \Magento\Framework\Controller\Result\RawFactory |
| 25 | + */ |
| 26 | + protected $resultRawFactory; |
| 27 | + |
23 | 28 | /**
|
24 | 29 | * @var \Magento\Framework\Url\DecoderInterface
|
25 | 30 | */
|
@@ -51,6 +56,7 @@ class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index
|
51 | 56 | * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
|
52 | 57 | * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
|
53 | 58 | * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
|
| 59 | + * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory |
54 | 60 | * @param \Magento\Framework\Url\DecoderInterface $urlDecoder
|
55 | 61 | *
|
56 | 62 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
@@ -81,6 +87,7 @@ public function __construct(
|
81 | 87 | \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
|
82 | 88 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
|
83 | 89 | \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
|
| 90 | + \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, |
84 | 91 | \Magento\Framework\Url\DecoderInterface $urlDecoder
|
85 | 92 | ) {
|
86 | 93 | parent::__construct(
|
@@ -110,6 +117,7 @@ public function __construct(
|
110 | 117 | $resultForwardFactory,
|
111 | 118 | $resultJsonFactory
|
112 | 119 | );
|
| 120 | + $this->resultRawFactory = $resultRawFactory; |
113 | 121 | $this->urlDecoder = $urlDecoder;
|
114 | 122 | }
|
115 | 123 |
|
@@ -151,6 +159,8 @@ public function execute()
|
151 | 159 | throw new NotFoundException();
|
152 | 160 | }
|
153 | 161 |
|
| 162 | + /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ |
| 163 | + $resultRaw = $this->resultRawFactory->create(); |
154 | 164 | if ($plain) {
|
155 | 165 | $extension = pathinfo($path, PATHINFO_EXTENSION);
|
156 | 166 | switch (strtolower($extension)) {
|
@@ -180,12 +190,15 @@ public function execute()
|
180 | 190 | ->clearBody();
|
181 | 191 | $this->getResponse()->sendHeaders();
|
182 | 192 |
|
183 |
| - echo $directory->readFile($fileName); |
| 193 | + $resultRaw->setContents($directory->readFile($fileName)); |
184 | 194 | } else {
|
185 | 195 | $name = pathinfo($path, PATHINFO_BASENAME);
|
186 |
| - $this->_fileFactory->create($name, ['type' => 'filename', 'value' => $fileName], DirectoryList::MEDIA) |
187 |
| - ->sendResponse(); |
| 196 | + $this->_response = $this->_fileFactory->create( |
| 197 | + $name, |
| 198 | + ['type' => 'filename', 'value' => $fileName], |
| 199 | + DirectoryList::MEDIA |
| 200 | + ); |
188 | 201 | }
|
189 |
| - exit; |
| 202 | + return $resultRaw; |
190 | 203 | }
|
191 | 204 | }
|
0 commit comments