/** * @param ConfigureMenuEvent $event */ public function onNavigationConfigure(ConfigureMenuEvent $event) { foreach ((array) $this->settings->getSettings(SettingsProvider::DATA_PATH) as $setting) { if (!$this->state->isEntityEnabled($setting['name'])) { continue; } foreach ($setting['navigation_items'] as $item) { $navigateArray = explode('.', $item); $menu = $event->getMenu(); if ($menu->getName() !== $navigateArray[0]) { continue; } $navigateArrayCount = count($navigateArray); for ($i = 1; $i < $navigateArrayCount; $i++) { if ($menu->getChild($navigateArray[$i])) { /** redefinition of variable $menu */ $menu = $menu->getChild($navigateArray[$i]); } if ($menu && !$menu->isDisplayed()) { $menu->setDisplay(true); } } } } }
/** * @param string $method * @param array $args * * @throws \RuntimeException * @throws \LogicException * @return bool */ public function __call($method, $args) { if (!$this->stateProvider) { throw new \RuntimeException('Provider configured incorrectly, missed "state provider"'); } if (preg_match('#(isEntity)(\\w+)(Enabled)#', $method, $matches)) { $entityName = rtrim($this->namespace, '\\') . '\\' . $matches[2]; if (class_exists($entityName)) { return $this->stateProvider->isEntityEnabled($entityName); } else { throw new \LogicException(sprintf('Unable to check state for "%s". Class does not exist', $entityName)); } } }
/** * @param string $entityFQCN entity full class name * * @return bool */ protected function isIncludedByChannels($entityFQCN) { if ($this->settingsProvider->isChannelEntity($entityFQCN)) { return $this->stateProvider->isEntityEnabled($entityFQCN); } elseif ($this->settingsProvider->isDependentOnChannelEntity($entityFQCN)) { $enabled = false; $dependencies = $this->settingsProvider->getDependentEntityData($entityFQCN); foreach ($dependencies as $entityName) { $enabled |= $this->stateProvider->isEntityEnabled($entityName); } return $enabled; } return true; }