7
7
8
8
namespace Magento \Sales \Controller \Adminhtml \Order ;
9
9
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 ;
12
13
use Magento \Sales \Api \OrderManagementInterface ;
13
14
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 ;
15
18
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 ;
17
27
28
+ /**
29
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
31
+ */
18
32
class AddressSave extends Order
19
33
{
20
34
/**
@@ -30,31 +44,29 @@ class AddressSave extends Order
30
44
private $ regionFactory ;
31
45
32
46
/**
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
41
55
* @param OrderManagementInterface $orderManagement
42
56
* @param OrderRepositoryInterface $orderRepository
43
57
* @param LoggerInterface $logger
44
58
* @param RegionFactory $regionFactory
45
59
*
46
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
47
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
48
60
*/
49
61
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 ,
58
70
OrderManagementInterface $ orderManagement ,
59
71
OrderRepositoryInterface $ orderRepository ,
60
72
LoggerInterface $ logger ,
@@ -79,14 +91,14 @@ public function __construct(
79
91
/**
80
92
* Save order address
81
93
*
82
- * @return \Magento\Backend\Model\View\Result\ Redirect
94
+ * @return Redirect
83
95
*/
84
96
public function execute ()
85
97
{
86
98
$ addressId = $ this ->getRequest ()->getParam ('address_id ' );
87
- /** @var $address \Magento\Sales\Api\Data\ OrderAddressInterface|\Magento\Sales\Model\Order\ Address */
99
+ /** @var $address OrderAddressInterface|Address */
88
100
$ address = $ this ->_objectManager ->create (
89
- \ Magento \ Sales \ Api \ Data \ OrderAddressInterface::class
101
+ OrderAddressInterface::class
90
102
)->load ($ addressId );
91
103
$ data = $ this ->getRequest ()->getPostValue ();
92
104
$ this ->updateRegionData ($ data );
@@ -103,7 +115,7 @@ public function execute()
103
115
);
104
116
$ this ->messageManager ->addSuccess (__ ('You updated the order address. ' ));
105
117
return $ resultRedirect ->setPath ('sales/*/view ' , ['order_id ' => $ address ->getParentId ()]);
106
- } catch (\ Magento \ Framework \ Exception \ LocalizedException $ e ) {
118
+ } catch (LocalizedException $ e ) {
107
119
$ this ->messageManager ->addError ($ e ->getMessage ());
108
120
} catch (\Exception $ e ) {
109
121
$ this ->messageManager ->addException ($ e , __ ('We can \'t update the order address right now. ' ));
@@ -119,7 +131,6 @@ public function execute()
119
131
*
120
132
* @param array $attributeValues
121
133
* @return void
122
- * @SuppressWarnings(PHPMD.NPathComplexity)
123
134
*/
124
135
protected function updateRegionData (&$ attributeValues )
125
136
{
0 commit comments