Skip to content

Commit 0b8885b

Browse files
author
vpaladiychuk
committed
Merge remote-tracking branch 'origin/MAGETWO-31522' into MAGETWO-31522
2 parents e33293d + 453f2df commit 0b8885b

File tree

11 files changed

+96
-53
lines changed

11 files changed

+96
-53
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,51 @@ class Order extends \Magento\Backend\App\Action
4848
*/
4949
protected $resultRedirectFactory;
5050

51+
/**
52+
* @var \Magento\Framework\Controller\Result\JSONFactory
53+
*/
54+
protected $resultJsonFactory;
55+
56+
/**
57+
* @var \Magento\Framework\View\Result\LayoutFactory
58+
*/
59+
protected $resultLayoutFactory;
60+
61+
/**
62+
* @var \Magento\Framework\Controller\Result\RawFactory
63+
*/
64+
protected $resultRawFactory;
65+
5166
/**
5267
* @param Action\Context $context
5368
* @param \Magento\Framework\Registry $coreRegistry
5469
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
5570
* @param \Magento\Framework\Translate\InlineInterface $translateInline
5671
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
5772
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
73+
* @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
74+
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
75+
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
5876
*/
5977
public function __construct(
6078
Action\Context $context,
6179
\Magento\Framework\Registry $coreRegistry,
6280
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
6381
\Magento\Framework\Translate\InlineInterface $translateInline,
6482
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
65-
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
83+
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
84+
\Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
85+
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
86+
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory
6687
) {
6788
$this->_coreRegistry = $coreRegistry;
6889
$this->_fileFactory = $fileFactory;
6990
$this->_translateInline = $translateInline;
7091
$this->resultPageFactory = $resultPageFactory;
7192
$this->resultRedirectFactory = $resultRedirectFactory;
93+
$this->resultJsonFactory = $resultJsonFactory;
94+
$this->resultLayoutFactory = $resultLayoutFactory;
95+
$this->resultRawFactory = $resultRawFactory;
7296
parent::__construct($context);
7397
}
7498

app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Order
1414
/**
1515
* Add order comment action
1616
*
17-
* @return void
17+
* @return \Magento\Framework\Controller\ResultInterface
1818
*/
1919
public function execute()
2020
{
2121
$order = $this->_initOrder();
2222
if ($order) {
2323
try {
24-
$response = false;
2524
$data = $this->getRequest()->getPost('history');
2625
if (empty($data['comment']) && $data['status'] == $order->getDataByKey('status')) {
2726
throw new \Magento\Framework\Model\Exception(__('Comment text cannot be empty.'));
@@ -44,17 +43,18 @@ public function execute()
4443

4544
$orderCommentSender->send($order, $notify, $comment);
4645

47-
$this->_view->loadLayout();
48-
$this->_view->renderLayout();
46+
return $this->resultPageFactory->create();
4947
} catch (\Magento\Framework\Model\Exception $e) {
5048
$response = ['error' => true, 'message' => $e->getMessage()];
5149
} catch (\Exception $e) {
5250
$response = ['error' => true, 'message' => __('We cannot add order history.')];
5351
}
5452
if (is_array($response)) {
55-
$response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response);
56-
$this->getResponse()->representJson($response);
53+
$resultJson = $this->resultJsonFactory->create();
54+
$resultJson->setData($response);
55+
return $resultJson;
5756
}
5857
}
58+
return $this->resultRedirectFactory->create()->setPath('sales/*/');
5959
}
6060
}

app/code/Magento/Sales/Controller/Adminhtml/Order/Address.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,29 @@
66
*/
77
namespace Magento\Sales\Controller\Adminhtml\Order;
88

9-
109
class Address extends \Magento\Sales\Controller\Adminhtml\Order
1110
{
1211
/**
1312
* Edit order address form
1413
*
15-
* @return void
14+
* @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
1615
*/
1716
public function execute()
1817
{
1918
$addressId = $this->getRequest()->getParam('address_id');
2019
$address = $this->_objectManager->create('Magento\Sales\Model\Order\Address')->load($addressId);
2120
if ($address->getId()) {
2221
$this->_coreRegistry->register('order_address', $address);
23-
$this->_view->loadLayout();
22+
$resultPage = $this->resultPageFactory->create();
2423
// Do not display VAT validation button on edit order address form
25-
$addressFormContainer = $this->_view->getLayout()->getBlock('sales_order_address.form.container');
24+
$addressFormContainer = $resultPage->getLayout()->getBlock('sales_order_address.form.container');
2625
if ($addressFormContainer) {
2726
$addressFormContainer->getChildBlock('form')->setDisplayVatValidationButton(false);
2827
}
2928

30-
$this->_view->renderLayout();
29+
return $resultPage;
3130
} else {
32-
$this->_redirect('sales/*/');
31+
return $this->resultRedirectFactory->create()->setPath('sales/*/');
3332
}
3433
}
3534
}

app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,33 @@
66
*/
77
namespace Magento\Sales\Controller\Adminhtml\Order;
88

9-
109
class AddressSave extends \Magento\Sales\Controller\Adminhtml\Order
1110
{
1211
/**
1312
* Save order address
1413
*
15-
* @return void
14+
* @return \Magento\Backend\Model\View\Result\Redirect
1615
*/
1716
public function execute()
1817
{
1918
$addressId = $this->getRequest()->getParam('address_id');
2019
$address = $this->_objectManager->create('Magento\Sales\Model\Order\Address')->load($addressId);
2120
$data = $this->getRequest()->getPost();
21+
$resultRedirect = $this->resultRedirectFactory->create();
2222
if ($data && $address->getId()) {
2323
$address->addData($data);
2424
try {
2525
$address->save();
2626
$this->messageManager->addSuccess(__('You updated the order address.'));
27-
$this->_redirect('sales/*/view', ['order_id' => $address->getParentId()]);
28-
return;
27+
return $resultRedirect->setPath('sales/*/view', ['order_id' => $address->getParentId()]);
2928
} catch (\Magento\Framework\Model\Exception $e) {
3029
$this->messageManager->addError($e->getMessage());
3130
} catch (\Exception $e) {
3231
$this->messageManager->addException($e, __('Something went wrong updating the order address.'));
3332
}
34-
$this->_redirect('sales/*/address', ['address_id' => $address->getId()]);
33+
return $resultRedirect->setPath('sales/*/address', ['address_id' => $address->getId()]);
3534
} else {
36-
$this->_redirect('sales/*/');
35+
return $resultRedirect->setPath('sales/*/');
3736
}
3837
}
3938
}

app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
*/
77
namespace Magento\Sales\Controller\Adminhtml\Order;
88

9-
109
class Cancel extends \Magento\Sales\Controller\Adminhtml\Order
1110
{
1211
/**
1312
* Cancel order
1413
*
15-
* @return void
14+
* @return \Magento\Backend\Model\View\Result\Redirect
1615
*/
1716
public function execute()
1817
{
1918
$order = $this->_initOrder();
19+
$resultRedirect = $this->resultRedirectFactory->create();
2020
if ($order) {
2121
try {
2222
$order->cancel()->save();
@@ -27,7 +27,8 @@ public function execute()
2727
$this->messageManager->addError(__('You have not canceled the item.'));
2828
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
2929
}
30-
$this->_redirect('sales/order/view', ['order_id' => $order->getId()]);
30+
return $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
3131
}
32+
return $resultRedirect->setPath('sales/*/');
3233
}
3334
}

app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66
*/
77
namespace Magento\Sales\Controller\Adminhtml\Order;
88

9-
109
class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
1110
{
1211
/**
1312
* Generate order history for ajax request
1413
*
15-
* @return void
14+
* @return \Magento\Framework\Controller\Result\Raw
1615
*/
1716
public function execute()
1817
{
1918
$this->_initOrder();
20-
21-
$html = $this->_view->getLayout()->createBlock(
22-
'Magento\Sales\Block\Adminhtml\Order\View\Tab\History'
23-
)->toHtml();
24-
19+
$resultPage = $this->resultPageFactory->create();
20+
$html = $resultPage->getLayout()->createBlock('Magento\Sales\Block\Adminhtml\Order\View\Tab\History')->toHtml();
2521
$this->_translateInline->processResponseBody($html);
22+
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
23+
$resultRaw = $this->resultRawFactory->create();
24+
$resultRaw->setContents($html);
2625

27-
$this->getResponse()->setBody($html);
26+
return $resultRaw;
2827
}
2928
}

app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemos.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Creditmemos extends \Magento\Sales\Controller\Adminhtml\Order
2222
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
2323
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
2424
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
25+
* @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
26+
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
2527
*/
2628
public function __construct(
2729
Action\Context $context,
@@ -30,7 +32,9 @@ public function __construct(
3032
\Magento\Framework\Translate\InlineInterface $translateInline,
3133
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
3234
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
33-
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
35+
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
36+
\Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
37+
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory
3438
) {
3539
$this->resultLayoutFactory = $resultLayoutFactory;
3640
parent::__construct(
@@ -39,7 +43,10 @@ public function __construct(
3943
$fileFactory,
4044
$translateInline,
4145
$resultPageFactory,
42-
$resultRedirectFactory
46+
$resultRedirectFactory,
47+
$resultJsonFactory,
48+
$resultLayoutFactory,
49+
$resultRawFactory
4350
);
4451
}
4552

app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,28 @@
55
*/
66
namespace Magento\Sales\Controller\Adminhtml\Order;
77

8-
9-
/**
10-
* Class Email
11-
*
12-
* @package Magento\Sales\Controller\Adminhtml\Order
13-
*/
148
class Email extends \Magento\Sales\Controller\Adminhtml\Order
159
{
1610
/**
1711
* Notify user
1812
*
19-
* @return void
13+
* @return \Magento\Backend\Model\View\Result\Redirect
2014
*/
2115
public function execute()
2216
{
2317
$order = $this->_initOrder();
2418
if ($order) {
2519
try {
26-
$this->_objectManager->create('Magento\Sales\Model\OrderNotifier')
27-
->notify($order);
20+
$this->_objectManager->create('Magento\Sales\Model\OrderNotifier')->notify($order);
2821
$this->messageManager->addSuccess(__('You sent the order email.'));
2922
} catch (\Magento\Framework\Model\Exception $e) {
3023
$this->messageManager->addError($e->getMessage());
3124
} catch (\Exception $e) {
3225
$this->messageManager->addError(__('We couldn\'t send the email order.'));
3326
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
3427
}
35-
$this->_redirect('sales/order/view', ['order_id' => $order->getId()]);
28+
return $this->resultRedirectFactory->create()->setPath('sales/order/view', ['order_id' => $order->getId()]);
3629
}
30+
return $this->resultRedirectFactory->create()->setPath('sales/*/');
3731
}
3832
}

app/code/Magento/Sales/Controller/Adminhtml/Order/ExportCsv.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ class ExportCsv extends \Magento\Sales\Controller\Adminhtml\Order
1414
/**
1515
* Export order grid to CSV format
1616
*
17-
* @return ResponseInterface|void
17+
* @return ResponseInterface
1818
*/
1919
public function execute()
2020
{
21-
$this->_view->loadLayout();
2221
$fileName = 'orders.csv';
2322
/** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */
24-
$exportBlock = $this->_view->getLayout()->getChildBlock('sales.order.grid', 'grid.export');
23+
$exportBlock = $this->resultLayoutFactory->create()
24+
->getLayout()
25+
->getChildBlock('sales.order.grid', 'grid.export');
2526
return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile(), DirectoryList::VAR_DIR);
2627
}
2728
}

app/code/Magento/Sales/Controller/Adminhtml/Order/ExportExcel.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@ class ExportExcel extends \Magento\Sales\Controller\Adminhtml\Order
1414
/**
1515
* Export order grid to Excel XML format
1616
*
17-
* @return ResponseInterface|void
17+
* @return ResponseInterface
1818
*/
1919
public function execute()
2020
{
21-
$this->_view->loadLayout();
2221
$fileName = 'orders.xml';
2322
/** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */
24-
$exportBlock = $this->_view->getLayout()->getChildBlock('sales.order.grid', 'grid.export');
25-
return $this->_fileFactory->create(
26-
$fileName,
27-
$exportBlock->getExcelFile($fileName),
28-
DirectoryList::VAR_DIR
29-
);
23+
$exportBlock = $this->resultLayoutFactory->create()
24+
->getLayout()
25+
->getChildBlock('sales.order.grid', 'grid.export');
26+
return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName), DirectoryList::VAR_DIR);
3027
}
3128
}

0 commit comments

Comments
 (0)