![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magefan/module-blog/Controller/Category/ |
<?php /** * Copyright © Magefan ([email protected]). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). * * Glory to Ukraine! Glory to the heroes! */ namespace Magefan\Blog\Controller\Category; /** * Blog category view */ class View extends \Magefan\Blog\App\Action\Action { /** * Store manager * * @var \Magento\Store\Model\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_storeManager = $storeManager; } /** * View blog category action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { if (!$this->moduleEnabled()) { return $this->_forwardNoroute(); } $category = $this->_initCategory(); if (!$category) { return $this->_forwardNoroute(); } $this->_objectManager->get(\Magento\Framework\Registry::class) ->register('current_blog_category', $category); $resultPage = $this->_objectManager->get(\Magefan\Blog\Helper\Page::class) ->prepareResultPage($this, $category); return $resultPage; } /** * Init category * * @return \Magefan\Blog\Model\category || false */ protected function _initCategory() { $id = (int)$this->getRequest()->getParam('id'); if (!$id) { return false; } $storeId = $this->_storeManager->getStore()->getId(); $category = $this->_objectManager->create(\Magefan\Blog\Model\Category::class)->load($id); if (!$category->isVisibleOnStore($storeId)) { return false; } $category->setStoreId($storeId); return $category; } }