Skip to content

Commit

Permalink
#94738 adjust Block/Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwaclawczyk committed Jul 8, 2024
1 parent cd2db76 commit a34f01f
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
namespace Snowdog\Menu\Block;

use Magento\Customer\Model\Session;
use Magento\Framework\Api\Search\FilterGroupBuilder;
use Magento\Framework\Api\Search\SearchCriteriaFactory;
use Magento\Framework\App\Cache\Type\Block;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\DataObject;
use Magento\Framework\View\Element\Template;
use Magento\Framework\Event\Manager as EventManager;
Expand All @@ -21,9 +18,13 @@

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Menu extends Template implements DataObject\IdentityInterface
{
const XML_SNOWMENU_GENERAL_CUSTOMER_GROUPS = 'snowmenu/general/customer_groups';

/**
* @var MenuRepositoryInterface
*/
Expand All @@ -43,15 +44,6 @@ class Menu extends Template implements DataObject\IdentityInterface

private $menu = null;

/**
* @var SearchCriteriaFactory
*/
private $searchCriteriaFactory;

/**
* @var FilterGroupBuilder
*/
private $filterGroupBuilder;
/**
* @var EventManager
*/
Expand Down Expand Up @@ -92,11 +84,6 @@ class Menu extends Template implements DataObject\IdentityInterface
*/
private $customerSession;

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand All @@ -106,29 +93,23 @@ public function __construct(
MenuRepositoryInterface $menuRepository,
NodeRepositoryInterface $nodeRepository,
NodeTypeProvider $nodeTypeProvider,
SearchCriteriaFactory $searchCriteriaFactory,
FilterGroupBuilder $filterGroupBuilder,
TemplateResolver $templateResolver,
ImageFile $imageFile,
Escaper $escaper,
Session $customerSession,
ScopeConfigInterface $scopeConfig,
array $data = []
) {
parent::__construct($context, $data);
$this->menuRepository = $menuRepository;
$this->nodeRepository = $nodeRepository;
$this->nodeTypeProvider = $nodeTypeProvider;
$this->searchCriteriaFactory = $searchCriteriaFactory;
$this->filterGroupBuilder = $filterGroupBuilder;
$this->eventManager = $eventManager;
$this->templateResolver = $templateResolver;
$this->imageFile = $imageFile;
$this->escaper = $escaper;
$this->setTemplate($this->getMenuTemplate($this->_template));
$this->submenuTemplate = $this->getSubmenuTemplate();
$this->customerSession = $customerSession;
$this->scopeConfig = $scopeConfig;
}

/**
Expand Down Expand Up @@ -194,7 +175,7 @@ public function getCacheKeyInfo()
if ($nodeCacheKeyInfo) {
$info = array_merge($info, $nodeCacheKeyInfo);
}
if ($this->scopeConfig->isSetFlag('snowmenu/general/customer_groups')) {
if ($this->_scopeConfig->isSetFlag(self::XML_SNOWMENU_GENERAL_CUSTOMER_GROUPS)) {
$info[] = 'cust_group_' . $this->getCustomerGroupId();
}

Expand Down Expand Up @@ -463,7 +444,7 @@ private function fetchData()
{
$nodes = $this->nodeRepository->getByMenu($this->loadMenu()->getId());
$currentCustomerGroup = $this->getCustomerGroupId();
$customerGroupEnabled = $this->scopeConfig->getValue('snowmenu/general/customer_groups');
$customerGroupEnabled = $this->_scopeConfig->getValue(self::XML_SNOWMENU_GENERAL_CUSTOMER_GROUPS);
$result = [];
$types = [];
foreach ($nodes as $node) {
Expand Down

0 comments on commit a34f01f

Please sign in to comment.