Skip to content

Commit 900b05f

Browse files
committed
Error CBO coupling between object.
1 parent 7d2cfcd commit 900b05f

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

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

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@
77

88
namespace Magento\Sales\Controller\Adminhtml\Order;
99

10-
use Magento\Sales\Controller\Adminhtml\Order;
11-
use Magento\Backend\App\Action;
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\Backend\Model\View\Result\Redirect;
12+
use Magento\Directory\Model\RegionFactory;
1213
use Magento\Sales\Api\OrderManagementInterface;
1314
use Magento\Sales\Api\OrderRepositoryInterface;
14-
use Magento\Directory\Model\RegionFactory;
15+
use Magento\Sales\Api\Data\OrderAddressInterface;
16+
use Magento\Sales\Controller\Adminhtml\Order;
17+
use Magento\Sales\Model\Order\Address;
1518
use Psr\Log\LoggerInterface;
16-
use Magento\Framework;
19+
use Magento\Framework\Registry;
20+
use Magento\Framework\App\Response\Http\FileFactory;
21+
use Magento\Framework\Translate\InlineInterface;
22+
use Magento\Framework\View\Result\PageFactory;
23+
use Magento\Framework\Controller\Result\JsonFactory;
24+
use Magento\Framework\View\Result\LayoutFactory;
25+
use Magento\Framework\Controller\Result\RawFactory;
26+
use Magento\Framework\Exception\LocalizedException;
1727

28+
/**
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
31+
*/
1832
class AddressSave extends Order
1933
{
2034
/**
@@ -30,31 +44,29 @@ class AddressSave extends Order
3044
private $regionFactory;
3145

3246
/**
33-
* @param Action\Context $context
34-
* @param Framework\Registry $coreRegistry
35-
* @param Framework\App\Response\Http\FileFactory $fileFactory
36-
* @param Framework\Translate\InlineInterface $translateInline
37-
* @param Framework\View\Result\PageFactory $resultPageFactory
38-
* @param Framework\Controller\Result\JsonFactory $resultJsonFactory
39-
* @param Framework\View\Result\LayoutFactory $resultLayoutFactory
40-
* @param Framework\Controller\Result\RawFactory $resultRawFactory
47+
* @param Context $context
48+
* @param Registry $coreRegistry
49+
* @param FileFactory $fileFactory
50+
* @param InlineInterface $translateInline
51+
* @param PageFactory $resultPageFactory
52+
* @param JsonFactory $resultJsonFactory
53+
* @param LayoutFactory $resultLayoutFactory
54+
* @param RawFactory $resultRawFactory
4155
* @param OrderManagementInterface $orderManagement
4256
* @param OrderRepositoryInterface $orderRepository
4357
* @param LoggerInterface $logger
4458
* @param RegionFactory $regionFactory
4559
*
46-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
47-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4860
*/
4961
public function __construct(
50-
Action\Context $context,
51-
Framework\Registry $coreRegistry,
52-
Framework\App\Response\Http\FileFactory $fileFactory,
53-
Framework\Translate\InlineInterface $translateInline,
54-
Framework\View\Result\PageFactory $resultPageFactory,
55-
Framework\Controller\Result\JsonFactory $resultJsonFactory,
56-
Framework\View\Result\LayoutFactory $resultLayoutFactory,
57-
Framework\Controller\Result\RawFactory $resultRawFactory,
62+
Context $context,
63+
Registry $coreRegistry,
64+
FileFactory $fileFactory,
65+
InlineInterface $translateInline,
66+
PageFactory $resultPageFactory,
67+
JsonFactory $resultJsonFactory,
68+
LayoutFactory $resultLayoutFactory,
69+
RawFactory $resultRawFactory,
5870
OrderManagementInterface $orderManagement,
5971
OrderRepositoryInterface $orderRepository,
6072
LoggerInterface $logger,
@@ -79,14 +91,14 @@ public function __construct(
7991
/**
8092
* Save order address
8193
*
82-
* @return \Magento\Backend\Model\View\Result\Redirect
94+
* @return Redirect
8395
*/
8496
public function execute()
8597
{
8698
$addressId = $this->getRequest()->getParam('address_id');
87-
/** @var $address \Magento\Sales\Api\Data\OrderAddressInterface|\Magento\Sales\Model\Order\Address */
99+
/** @var $address OrderAddressInterface|Address */
88100
$address = $this->_objectManager->create(
89-
\Magento\Sales\Api\Data\OrderAddressInterface::class
101+
OrderAddressInterface::class
90102
)->load($addressId);
91103
$data = $this->getRequest()->getPostValue();
92104
$this->updateRegionData($data);
@@ -103,7 +115,7 @@ public function execute()
103115
);
104116
$this->messageManager->addSuccess(__('You updated the order address.'));
105117
return $resultRedirect->setPath('sales/*/view', ['order_id' => $address->getParentId()]);
106-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
118+
} catch (LocalizedException $e) {
107119
$this->messageManager->addError($e->getMessage());
108120
} catch (\Exception $e) {
109121
$this->messageManager->addException($e, __('We can\'t update the order address right now.'));
@@ -119,7 +131,6 @@ public function execute()
119131
*
120132
* @param array $attributeValues
121133
* @return void
122-
* @SuppressWarnings(PHPMD.NPathComplexity)
123134
*/
124135
protected function updateRegionData(&$attributeValues)
125136
{

0 commit comments

Comments
 (0)