File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,24 @@ class View extends \Magefan\Blog\App\Action\Action
2020 protected $ _storeManager ;
2121
2222 /**
23+ * @var \Magefan\Blog\Model\Url
24+ */
25+ protected $ url ;
26+
27+ /**
28+ * View constructor.
2329 * @param \Magento\Framework\App\Action\Context $context
2430 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
31+ * @param \Magefan\Blog\Model\Url|null $url
2532 */
2633 public function __construct (
2734 \Magento \Framework \App \Action \Context $ context ,
28- \Magento \Store \Model \StoreManagerInterface $ storeManager
35+ \Magento \Store \Model \StoreManagerInterface $ storeManager ,
36+ \Magefan \Blog \Model \Url $ url = null
2937 ) {
3038 parent ::__construct ($ context );
3139 $ this ->_storeManager = $ storeManager ;
40+ $ this ->url = $ url ?: $ this ->_objectManager ->get (\Magefan \Blog \Model \Url::class);
3241 }
3342
3443 /**
@@ -43,8 +52,12 @@ public function execute()
4352 }
4453
4554 $ category = $ this ->_initCategory ();
55+
4656 if (!$ category ) {
47- return $ this ->_forwardNoroute ();
57+ $ resultRedirect = $ this ->resultRedirectFactory ->create ();
58+ $ resultRedirect ->setHttpResponseCode (301 );
59+ $ resultRedirect ->setPath ($ this ->url ->getBaseUrl ());
60+ return $ resultRedirect ;
4861 }
4962
5063 $ this ->_objectManager ->get (\Magento \Framework \Registry::class)
You can’t perform that action at this time.
0 commit comments