8
8
namespace Magento \Catalog \Controller \Adminhtml ;
9
9
10
10
use Magento \Store \Model \Store ;
11
+ use Magento \Backend \App \Action \Context ;
12
+ use Magento \Framework \Stdlib \DateTime \Filter \Date ;
13
+ use Magento \Catalog \Model \Category as CategoryModel ;
14
+ use Magento \Backend \App \Action ;
15
+ use Magento \Store \Model \StoreManagerInterface ;
16
+ use Magento \Framework \Registry ;
17
+ use Magento \Cms \Model \Wysiwyg \Config ;
18
+ use Magento \Backend \Model \View \Result \Page ;
19
+ use Magento \Framework \Controller \Result \Json ;
20
+ use Magento \Backend \Model \Auth \Session ;
21
+ use Magento \Framework \DataObject ;
22
+ use Zend_Filter_Input ;
11
23
12
24
/**
13
25
* Catalog category controller
14
26
*/
15
- abstract class Category extends \ Magento \ Backend \ App \ Action
27
+ abstract class Category extends Action
16
28
{
17
29
/**
18
30
* Authorization level of a basic admin session
@@ -22,17 +34,17 @@ abstract class Category extends \Magento\Backend\App\Action
22
34
const ADMIN_RESOURCE = 'Magento_Catalog::categories ' ;
23
35
24
36
/**
25
- * @var \Magento\Framework\Stdlib\DateTime\Filter\ Date
37
+ * @var Date
26
38
*/
27
39
protected $ dateFilter ;
28
40
29
41
/**
30
- * @param \Magento\Backend\App\Action\ Context $context
31
- * @param \Magento\Framework\Stdlib\DateTime\Filter\ Date|null $dateFilter
42
+ * @param Context $context
43
+ * @param Date|null $dateFilter
32
44
*/
33
45
public function __construct (
34
- \ Magento \ Backend \ App \ Action \ Context $ context ,
35
- \ Magento \ Framework \ Stdlib \ DateTime \ Filter \ Date $ dateFilter = null
46
+ Context $ context ,
47
+ Date $ dateFilter = null
36
48
) {
37
49
$ this ->dateFilter = $ dateFilter ;
38
50
parent ::__construct ($ context );
@@ -43,20 +55,20 @@ public function __construct(
43
55
* Root category can be returned, if inappropriate store/category is specified
44
56
*
45
57
* @param bool $getRootInstead
46
- * @return \Magento\Catalog\Model\Category |false
58
+ * @return CategoryModel |false
47
59
*/
48
60
protected function _initCategory (bool $ getRootInstead = false )
49
61
{
50
62
$ categoryId = $ this ->resolveCategoryId ();
51
63
$ storeId = $ this ->resolveStoreId ();
52
- $ category = $ this ->_objectManager ->create (\ Magento \ Catalog \ Model \Category ::class);
64
+ $ category = $ this ->_objectManager ->create (CategoryModel ::class);
53
65
$ category ->setStoreId ($ storeId );
54
66
55
67
if ($ categoryId ) {
56
68
$ category ->load ($ categoryId );
57
69
if ($ storeId ) {
58
70
$ rootId = $ this ->_objectManager ->get (
59
- \ Magento \ Store \ Model \ StoreManagerInterface::class
71
+ StoreManagerInterface::class
60
72
)->getStore (
61
73
$ storeId
62
74
)->getRootCategoryId ();
@@ -71,9 +83,9 @@ protected function _initCategory(bool $getRootInstead = false)
71
83
}
72
84
}
73
85
74
- $ this ->_objectManager ->get (\ Magento \ Framework \ Registry::class)->register ('category ' , $ category );
75
- $ this ->_objectManager ->get (\ Magento \ Framework \ Registry::class)->register ('current_category ' , $ category );
76
- $ this ->_objectManager ->get (\ Magento \ Cms \ Model \ Wysiwyg \ Config::class)
86
+ $ this ->_objectManager ->get (Registry::class)->register ('category ' , $ category );
87
+ $ this ->_objectManager ->get (Registry::class)->register ('current_category ' , $ category );
88
+ $ this ->_objectManager ->get (Config::class)
77
89
->setStoreId ($ this ->getRequest ()->getParam ('store ' ));
78
90
return $ category ;
79
91
}
@@ -105,26 +117,26 @@ private function resolveStoreId(): int
105
117
return $ storeId ?: (int )$ this ->getRequest ()->getParam ('store_id ' , Store::DEFAULT_STORE_ID );
106
118
}
107
119
108
- /**
120
+ /**Zend_Filter_Input
109
121
* Build response for ajax request
110
122
*
111
- * @param \Magento\Catalog\Model\Category $category
112
- * @param \Magento\Backend\Model\View\Result\ Page $resultPage
123
+ * @param CategoryModel $category
124
+ * @param Page $resultPage
113
125
*
114
- * @return \Magento\Framework\Controller\Result\ Json
126
+ * @return Json
115
127
*
116
128
* @deprecated 101.0.0
117
129
*/
118
130
protected function ajaxRequestResponse (
119
- \ Magento \ Catalog \ Model \ Category $ category ,
120
- \ Magento \ Backend \ Model \ View \ Result \ Page $ resultPage
121
- ): \ Magento \ Framework \ Controller \ Result \ Json {
131
+ CategoryModel $ category ,
132
+ Page $ resultPage
133
+ ): Json {
122
134
// prepare breadcrumbs of selected category, if any
123
135
$ breadcrumbsPath = $ category ->getPath ();
124
136
if (empty ($ breadcrumbsPath )) {
125
137
// but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
126
138
$ breadcrumbsPath = $ this ->_objectManager ->get (
127
- \ Magento \ Backend \ Model \ Auth \ Session::class
139
+ Session::class
128
140
)->getDeletedPath (
129
141
true
130
142
);
@@ -140,7 +152,7 @@ protected function ajaxRequestResponse(
140
152
}
141
153
}
142
154
143
- $ eventResponse = new \ Magento \ Framework \ DataObject ([
155
+ $ eventResponse = new DataObject ([
144
156
'content ' => $ resultPage ->getLayout ()->getUiComponent ('category_form ' )->getFormHtml ()
145
157
. $ resultPage ->getLayout ()->getBlock ('category.tree ' )
146
158
->getBreadcrumbsJavascript ($ breadcrumbsPath , 'editingCategoryBreadcrumbs ' ),
@@ -151,8 +163,8 @@ protected function ajaxRequestResponse(
151
163
'category_prepare_ajax_response ' ,
152
164
['response ' => $ eventResponse , 'controller ' => $ this ]
153
165
);
154
- /** @var \Magento\Framework\Controller\Result\ Json $resultJson */
155
- $ resultJson = $ this ->_objectManager ->get (\ Magento \ Framework \ Controller \ Result \ Json::class);
166
+ /** @var Json $resultJson */
167
+ $ resultJson = $ this ->_objectManager ->get (Json::class);
156
168
$ resultJson ->setHeader ('Content-type ' , 'application/json ' , true );
157
169
$ resultJson ->setData ($ eventResponse ->getData ());
158
170
return $ resultJson ;
@@ -161,12 +173,12 @@ protected function ajaxRequestResponse(
161
173
/**
162
174
* Datetime data preprocessing
163
175
*
164
- * @param \Magento\Catalog\Model\Category $category
176
+ * @param CategoryModel $category
165
177
* @param array $postData
166
178
*
167
179
* @return array
168
180
*/
169
- protected function dateTimePreprocessing (\ Magento \ Catalog \ Model \ Category $ category , array $ postData ): array
181
+ protected function dateTimePreprocessing (CategoryModel $ category , array $ postData ): array
170
182
{
171
183
$ dateFieldFilters = [];
172
184
$ attributes = $ category ->getAttributes ();
@@ -177,7 +189,7 @@ protected function dateTimePreprocessing(\Magento\Catalog\Model\Category $catego
177
189
}
178
190
}
179
191
}
180
- $ inputFilter = new \ Zend_Filter_Input ($ dateFieldFilters , [], $ postData );
192
+ $ inputFilter = new Zend_Filter_Input ($ dateFieldFilters , [], $ postData );
181
193
return $ inputFilter ->getUnescaped ();
182
194
}
183
195
}
0 commit comments