/** * Convert xml config paths to decorated names * * @param array $paths * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _getSystemConfigPathsParts($paths) { $result = $urlParams = $prefixParts = array(); $scopeLabel = __('GLOBAL'); if ($paths) { /** @var $menu \Magento\Backend\Model\Menu */ $menu = $this->_menuConfig->getMenu(); $item = $menu->get('Magento_Backend::stores'); // create prefix path parts $prefixParts[] = array('title' => __($item->getTitle())); $item = $menu->get('Magento_Backend::system_config'); $prefixParts[] = array('title' => __($item->getTitle()), 'url' => $this->getUrl('adminhtml/system_config/')); $pathParts = $prefixParts; foreach ($paths as $pathData) { $pathDataParts = explode('/', $pathData['path']); $sectionName = array_shift($pathDataParts); $urlParams = array('section' => $sectionName); if (isset($pathData['scope']) && isset($pathData['scope_id'])) { switch ($pathData['scope']) { case 'stores': $store = $this->_storeManager->getStore($pathData['scope_id']); if ($store) { $urlParams['website'] = $store->getWebsite()->getCode(); $urlParams['store'] = $store->getCode(); $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName(); } break; case 'websites': $website = $this->_storeManager->getWebsite($pathData['scope_id']); if ($website) { $urlParams['website'] = $website->getCode(); $scopeLabel = $website->getName(); } break; default: break; } } $pathParts[] = array('title' => $this->_configStructure->getElement($sectionName)->getLabel(), 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams)); $elementPathParts = array($sectionName); while (count($pathDataParts) != 1) { $elementPathParts[] = array_shift($pathDataParts); $pathParts[] = array('title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel()); } $elementPathParts[] = array_shift($pathDataParts); $pathParts[] = array('title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel(), 'scope' => $scopeLabel); $result[] = $pathParts; $pathParts = $prefixParts; } } return $result; }