arrayManager = $arrayManager; $this->themeList = $themeList; } /** * Change value from theme_full_path (Ex. "frontend/Magento/blank") to theme_id field for every existed scope. * All other values leave without changes. * * @param array $config * @return array */ public function process(array $config) { foreach ($config as $scope => &$item) { if ($scope === \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { $item = $this->changeThemeFullPathToIdentifier($item); } else { foreach ($item as &$scopeItems) { $scopeItems = $this->changeThemeFullPathToIdentifier($scopeItems); } } } return $config; } /** * Check \Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID config path * and convert theme_full_path (Ex. "frontend/Magento/blank") to theme_id * * @param array $configItems * @return array */ private function changeThemeFullPathToIdentifier($configItems) { $theme = null; $themeIdentifier = $this->arrayManager->get(DesignInterface::XML_PATH_THEME_ID, $configItems); if (!empty($themeIdentifier)) { if (!is_numeric($themeIdentifier)) { // workaround for case when db is not available try { $theme = $this->themeList->getThemeByFullPath($themeIdentifier); } catch (\DomainException $domainException) { $theme = null; } } if ($theme && $theme->getId()) { return $this->arrayManager->set(DesignInterface::XML_PATH_THEME_ID, $configItems, $theme->getId()); } } return $configItems; } }