7
7
namespace Magento \Backend \Controller \Adminhtml \System \Store ;
8
8
9
9
use Magento \Framework \App \Action \HttpPostActionInterface as HttpPostActionInterface ;
10
+ use Magento \Store \Model \Group as StoreGroup ;
11
+ use Magento \Store \Model \Store ;
12
+ use Magento \Framework \Exception \LocalizedException ;
10
13
11
14
/**
12
15
* Class Save
@@ -33,15 +36,14 @@ private function processWebsiteSave($postData)
33
36
$ websiteModel ->setId (null );
34
37
}
35
38
36
- $ groupModel = $ this ->_objectManager ->create (\ Magento \ Store \ Model \Group ::class);
39
+ $ groupModel = $ this ->_objectManager ->create (StoreGroup ::class);
37
40
$ groupModel ->load ($ websiteModel ->getDefaultGroupId ());
38
-
39
- $ storeModel = $ this ->_objectManager ->create (\Magento \Store \Model \Store::class);
41
+ $ storeModel = $ this ->_objectManager ->create (Store::class);
40
42
$ storeModel ->load ($ groupModel ->getDefaultStoreId ());
41
43
42
44
if ($ websiteModel ->getIsDefault () && !$ storeModel ->isActive ()) {
43
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
44
- __ (" Please enable your Store View before using this Web Site as Default " )
45
+ throw new LocalizedException (
46
+ __ (' Please enable your Store View before using this Web Site as Default ' )
45
47
);
46
48
}
47
49
@@ -55,13 +57,13 @@ private function processWebsiteSave($postData)
55
57
* Process Store model save
56
58
*
57
59
* @param array $postData
58
- * @throws \Magento\Framework\Exception\ LocalizedException
60
+ * @throws LocalizedException
59
61
* @return array
60
62
*/
61
63
private function processStoreSave ($ postData )
62
64
{
63
- /** @var \Magento\Store\Model\ Store $storeModel */
64
- $ storeModel = $ this ->_objectManager ->create (\ Magento \ Store \ Model \ Store::class);
65
+ /** @var Store $storeModel */
66
+ $ storeModel = $ this ->_objectManager ->create (Store::class);
65
67
$ postData ['store ' ]['name ' ] = $ this ->filterManager ->removeTags ($ postData ['store ' ]['name ' ]);
66
68
if ($ postData ['store ' ]['store_id ' ]) {
67
69
$ storeModel ->load ($ postData ['store ' ]['store_id ' ]);
@@ -71,13 +73,13 @@ private function processStoreSave($postData)
71
73
$ storeModel ->setId (null );
72
74
}
73
75
$ groupModel = $ this ->_objectManager ->create (
74
- \ Magento \ Store \ Model \Group ::class
76
+ StoreGroup ::class
75
77
)->load (
76
78
$ storeModel ->getGroupId ()
77
79
);
78
80
$ storeModel ->setWebsiteId ($ groupModel ->getWebsiteId ());
79
81
if (!$ storeModel ->isActive () && $ storeModel ->isDefault ()) {
80
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
82
+ throw new LocalizedException (
81
83
__ ('The default store cannot be disabled ' )
82
84
);
83
85
}
@@ -91,14 +93,14 @@ private function processStoreSave($postData)
91
93
* Process StoreGroup model save
92
94
*
93
95
* @param array $postData
94
- * @throws \Magento\Framework\Exception\ LocalizedException
96
+ * @throws LocalizedException
95
97
* @return array
96
98
*/
97
99
private function processGroupSave ($ postData )
98
100
{
99
101
$ postData ['group ' ]['name ' ] = $ this ->filterManager ->removeTags ($ postData ['group ' ]['name ' ]);
100
- /** @var \Magento\Store\Model\Group $groupModel */
101
- $ groupModel = $ this ->_objectManager ->create (\ Magento \ Store \ Model \Group ::class);
102
+ /** @var StoreGroup $groupModel */
103
+ $ groupModel = $ this ->_objectManager ->create (StoreGroup ::class);
102
104
if ($ postData ['group ' ]['group_id ' ]) {
103
105
$ groupModel ->load ($ postData ['group ' ]['group_id ' ]);
104
106
}
@@ -107,7 +109,7 @@ private function processGroupSave($postData)
107
109
$ groupModel ->setId (null );
108
110
}
109
111
if (!$ this ->isSelectedDefaultStoreActive ($ postData , $ groupModel )) {
110
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
112
+ throw new LocalizedException (
111
113
__ ('An inactive store view cannot be saved as default store view ' )
112
114
);
113
115
}
@@ -148,7 +150,7 @@ public function execute()
148
150
}
149
151
$ redirectResult ->setPath ('adminhtml/*/ ' );
150
152
return $ redirectResult ;
151
- } catch (\ Magento \ Framework \ Exception \ LocalizedException $ e ) {
153
+ } catch (LocalizedException $ e ) {
152
154
$ this ->messageManager ->addErrorMessage ($ e ->getMessage ());
153
155
$ this ->_getSession ()->setPostData ($ postData );
154
156
} catch (\Exception $ e ) {
@@ -169,10 +171,10 @@ public function execute()
169
171
* Verify if selected default store is active
170
172
*
171
173
* @param array $postData
172
- * @param \Magento\Store\Model\Group $groupModel
174
+ * @param StoreGroup $groupModel
173
175
* @return bool
174
176
*/
175
- private function isSelectedDefaultStoreActive (array $ postData , \ Magento \ Store \ Model \ Group $ groupModel )
177
+ private function isSelectedDefaultStoreActive (array $ postData , StoreGroup $ groupModel )
176
178
{
177
179
if (!empty ($ postData ['group ' ]['default_store_id ' ])) {
178
180
$ defaultStoreId = $ postData ['group ' ]['default_store_id ' ];
0 commit comments