Chris@0: configStorage = $config_storage; Chris@0: $this->languageManager = $language_manager; Chris@0: Chris@0: $this->requiredInstallStorage = new ExtensionInstallStorage($this->configStorage, ExtensionInstallStorage::CONFIG_INSTALL_DIRECTORY, ExtensionInstallStorage::DEFAULT_COLLECTION, TRUE, $install_profile); Chris@0: $this->optionalInstallStorage = new ExtensionInstallStorage($this->configStorage, ExtensionInstallStorage::CONFIG_OPTIONAL_DIRECTORY, ExtensionInstallStorage::DEFAULT_COLLECTION, TRUE, $install_profile); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Read a configuration from install storage or default languages. Chris@0: * Chris@0: * @param string $name Chris@0: * Configuration object name. Chris@0: * Chris@0: * @return array Chris@0: * Configuration data from install storage or default language. Chris@0: */ Chris@0: public function read($name) { Chris@0: if ($this->requiredInstallStorage->exists($name)) { Chris@0: return $this->requiredInstallStorage->read($name); Chris@0: } Chris@0: elseif ($this->optionalInstallStorage->exists($name)) { Chris@0: return $this->optionalInstallStorage->read($name); Chris@0: } Chris@0: elseif (strpos($name, 'language.entity.') === 0) { Chris@0: // Simulate default languages as if they were shipped as default Chris@0: // configuration. Chris@0: $langcode = str_replace('language.entity.', '', $name); Chris@0: $predefined_languages = $this->languageManager->getStandardLanguageList(); Chris@0: if (isset($predefined_languages[$langcode])) { Chris@0: $data = $this->configStorage->read($name); Chris@0: $data['label'] = $predefined_languages[$langcode][0]; Chris@0: return $data; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Return the list of configuration in install storage and current languages. Chris@0: * Chris@0: * @return array Chris@0: * List of configuration in install storage and current languages. Chris@0: */ Chris@0: public function listAll() { Chris@0: $languages = $this->predefinedConfiguredLanguages(); Chris@0: return array_unique( Chris@0: array_merge( Chris@0: $this->requiredInstallStorage->listAll(), Chris@0: $this->optionalInstallStorage->listAll(), Chris@0: $languages Chris@0: ) Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get all configuration names and folders for a list of modules or themes. Chris@0: * Chris@0: * @param string $type Chris@0: * Type of components: 'module' | 'theme' | 'profile' Chris@0: * @param array $list Chris@0: * Array of theme or module names. Chris@0: * Chris@0: * @return array Chris@0: * Configuration names provided by that component. In case of language Chris@0: * module this list is extended with configured languages that have Chris@0: * predefined names as well. Chris@0: */ Chris@0: public function getComponentNames($type, array $list) { Chris@0: $names = array_unique( Chris@0: array_merge( Chris@0: array_keys($this->requiredInstallStorage->getComponentNames($type, $list)), Chris@0: array_keys($this->optionalInstallStorage->getComponentNames($type, $list)) Chris@0: ) Chris@0: ); Chris@0: if ($type == 'module' && in_array('language', $list)) { Chris@0: $languages = $this->predefinedConfiguredLanguages(); Chris@0: $names = array_unique(array_merge($names, $languages)); Chris@0: } Chris@0: return $names; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Compute the list of configuration names that match predefined languages. Chris@0: * Chris@0: * @return array Chris@0: * The list of configuration names that match predefined languages. Chris@0: */ Chris@0: protected function predefinedConfiguredLanguages() { Chris@0: $names = $this->configStorage->listAll('language.entity.'); Chris@0: $predefined_languages = $this->languageManager->getStandardLanguageList(); Chris@0: foreach ($names as $id => $name) { Chris@0: $langcode = str_replace('language.entity.', '', $name); Chris@0: if (!isset($predefined_languages[$langcode])) { Chris@0: unset($names[$id]); Chris@0: } Chris@0: } Chris@0: return array_values($names); Chris@0: } Chris@0: Chris@0: }