deploymentConfig = $deploymentConfig; $this->themeFactory = $themeFactory; $this->dataObjectFactory = $dataObjectFactory; } /** * Retrieves configuration data array. * Example: * * ```php * ['adminhtml/Magento/backend' => * [ * 'parent_id' => NULL, * 'theme_path' => 'Magento/backend', * 'theme_title' => 'Magento 2 backend', * 'is_featured' => '0', * 'area' => 'adminhtml', * 'type' => '0', * 'code' => 'Magento/backend', * ] * ] * ``` * * @param string $path The path to theme configuration. * @return array The data array with theme configurations. */ public function get($path = '') { if (!$this->deploymentConfig->isDbAvailable()) { return []; } if (!$this->data) { $rawThemes = $this->fetchThemes(); $themes = []; foreach ($rawThemes as $themeRow) { unset($themeRow['theme_id'], $themeRow['preview_image']); $themePath = $themeRow['area'] . '/' . $themeRow['theme_path']; $themes[$themePath] = $themeRow; if (isset($rawThemes[$themeRow['parent_id']]['code'])) { $themes[$themePath]['parent_id'] = $rawThemes[$themeRow['parent_id']]['code']; } } $this->data = $this->dataObjectFactory->create($themes); } return $this->data->getData($path) ?: []; } /** * Fetches themes from data source. * * @return array An associative list with found themes */ private function fetchThemes() { /** @var Theme $theme */ $theme = $this->themeFactory->create(); $select = $theme->getConnection()->select() ->from($theme->getMainTable()) ->order('theme_id'); return $theme->getConnection()->fetchAssoc($select); } }