@@ -52,6 +52,16 @@ class View extends \Magento\Framework\App\Action\Action
52
52
*/
53
53
protected $ resultPageFactory ;
54
54
55
+ /**
56
+ * @var \Magento\Framework\Controller\Result\ForwardFactory
57
+ */
58
+ protected $ resultForwardFactory ;
59
+
60
+ /**
61
+ * @var \Magento\Framework\Controller\Result\RedirectFactory
62
+ */
63
+ protected $ resultRedirectFactory ;
64
+
55
65
/**
56
66
* Catalog Layer Resolver
57
67
*
@@ -73,8 +83,10 @@ class View extends \Magento\Framework\App\Action\Action
73
83
* @param \Magento\Framework\Registry $coreRegistry
74
84
* @param \Magento\Framework\Store\StoreManagerInterface $storeManager
75
85
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
76
- * @param Resolver $layerResolver
77
86
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
87
+ * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
88
+ * @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory
89
+ * @param Resolver $layerResolver
78
90
* @param CategoryRepositoryInterface $categoryRepository
79
91
*/
80
92
public function __construct (
@@ -85,6 +97,8 @@ public function __construct(
85
97
\Magento \Framework \Store \StoreManagerInterface $ storeManager ,
86
98
\Magento \CatalogUrlRewrite \Model \CategoryUrlPathGenerator $ categoryUrlPathGenerator ,
87
99
PageFactory $ resultPageFactory ,
100
+ \Magento \Framework \Controller \Result \ForwardFactory $ resultForwardFactory ,
101
+ \Magento \Framework \Controller \Result \RedirectFactory $ resultRedirectFactory ,
88
102
Resolver $ layerResolver ,
89
103
CategoryRepositoryInterface $ categoryRepository
90
104
) {
@@ -95,6 +109,8 @@ public function __construct(
95
109
$ this ->_coreRegistry = $ coreRegistry ;
96
110
$ this ->categoryUrlPathGenerator = $ categoryUrlPathGenerator ;
97
111
$ this ->resultPageFactory = $ resultPageFactory ;
112
+ $ this ->resultForwardFactory = $ resultForwardFactory ;
113
+ $ this ->resultRedirectFactory = $ resultRedirectFactory ;
98
114
$ this ->layerResolver = $ layerResolver ;
99
115
$ this ->categoryRepository = $ categoryRepository ;
100
116
}
@@ -137,15 +153,14 @@ protected function _initCategory()
137
153
/**
138
154
* Category view action
139
155
*
140
- * @return \Magento\Framework\View\Result\Page
156
+ * @return \Magento\Framework\Controller\ResultInterface
141
157
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
142
158
* @SuppressWarnings(PHPMD.NPathComplexity)
143
159
*/
144
160
public function execute ()
145
161
{
146
162
if ($ this ->_request ->getParam (\Magento \Framework \App \Action \Action::PARAM_NAME_URL_ENCODED )) {
147
- $ this ->getResponse ()->setRedirect ($ this ->_redirect ->getRedirectUrl ());
148
- return ;
163
+ return $ this ->resultRedirectFactory ->create ()->setUrl ($ this ->_redirect ->getRedirectUrl ());
149
164
}
150
165
$ category = $ this ->_initCategory ();
151
166
if ($ category ) {
@@ -192,7 +207,7 @@ public function execute()
192
207
$ page ->getLayout ()->initMessages ();
193
208
return $ page ;
194
209
} elseif (!$ this ->getResponse ()->isRedirect ()) {
195
- $ this ->_forward ('noroute ' );
210
+ return $ this ->resultForwardFactory -> create ()-> forward ('noroute ' );
196
211
}
197
212
}
198
213
}
0 commit comments