configStructure = $configStructure; $this->request = $request; $this->informationList = $informationList; } /** * Get section id. * * @return string|null */ public function getId(): ?string { if ($section = $this->get()) { return $section->getId(); } return null; } /** * Get current section. * * @return \Magento\Config\Model\Config\Structure\Element\Section|null */ public function get(): ?Section { $current = $this->request->getParam('section', ''); if (! $current) { try { $section = $this->configStructure->getFirstSection(); } catch (LocalizedException $e) { $section = null; } } else { $section = $this->configStructure->getElement($current); if (! $section instanceof Section) { $section = null; } } return $section; } /** * Check if current section is related one of plumrocket extensions. * * Ad some extensions that customize admin menu can change tab we try check section id first. * * @return bool */ public function isPlumrocketExtension(): bool { if ($this->isPlumrocketSectionId($this->request->getParam('section', ''))) { return true; } $section = $this->get(); return $section && 'plumrocket' === $section->getAttribute('tab'); } /** * Check if section is declared in extensions.xml * * If the module consists of two sections, such as the Advanced Reviews and Reminders extension, * it may not function properly. * * @param string $sectionId * @return bool */ private function isPlumrocketSectionId(string $sectionId): bool { if (! $sectionId) { return false; } foreach ($this->informationList->getList()->getItems() as $extensionInformation) { if ($sectionId === $extensionInformation->getConfigSection()) { return true; } } return false; } }