diff --git a/core/core.services.yml b/core/core.services.yml index 38acedf..fe8d80d 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -93,8 +93,8 @@ services: class: Drupal\Core\Config\DatabaseStorage arguments: ['@database', config_snapshot] config.storage.schema: - class: Drupal\Core\Config\Schema\SchemaStorage - arguments: ['@config.storage'] + class: Drupal\Core\Config\ExtensionInstallStorage + arguments: ['@config.storage', 'config/schema'] config.storage.installer: class: Drupal\Core\Config\InstallStorage config.typed: diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index efaef95..ba797f0 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -7,11 +7,11 @@ namespace Drupal\Core\Config; -use Drupal\Core\Config\InstallStorage; -use Drupal\Core\Config\StorageException; - /** - * Defines the file storage controller for metadata files. + * Storage to access configuration and schema in enabled extensions. + * + * @see \Drupal\Core\Config\ConfigInstaller + * @see \Drupal\Core\Config\TypedConfigManager */ class ExtensionInstallStorage extends InstallStorage { @@ -28,16 +28,13 @@ class ExtensionInstallStorage extends InstallStorage { * @param \Drupal\Core\Config\StorageInterface $config_storage * The active configuration store where the list of enabled modules and * themes is stored. + * @param string $directory + * The directory to scan in each extension to scan for files. Defaults to + * 'config'. */ - public function __construct(StorageInterface $config_storage) { + public function __construct(StorageInterface $config_storage, $directory = 'config') { $this->configStorage = $config_storage; - } - - /** - * Resets the static cache. - */ - public function reset() { - $this->folders = NULL; + $this->directory = $directory; } /** diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index 124748a..cdc1719 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -30,9 +30,21 @@ class InstallStorage extends FileStorage { protected $folders; /** - * Overrides Drupal\Core\Config\FileStorage::__construct(). + * The directory to scan in each extension to scan for files. + * + * @var string */ - public function __construct() { + protected $directory; + + /** + * Constructs an InstallStorage object. + * + * @param string $directory + * The directory to scan in each extension to scan for files. Defaults to + * 'config'. + */ + public function __construct($directory = 'config') { + $this->directory = $directory; } /** @@ -65,12 +77,19 @@ public function getFilePath($name) { } /** + * {@inheritdoc} + */ + public function exists($name) { + return array_key_exists($name, $this->getAllFolders()); + } + + /** * Overrides Drupal\Core\Config\FileStorage::write(). * * @throws \Drupal\Core\Config\StorageException */ public function write($name, array $data) { - throw new StorageException('Write operation is not allowed during install.'); + throw new StorageException('Write operation is not allowed.'); } /** @@ -79,7 +98,7 @@ public function write($name, array $data) { * @throws \Drupal\Core\Config\StorageException */ public function delete($name) { - throw new StorageException('Delete operation is not allowed during install.'); + throw new StorageException('Delete operation is not allowed.'); } /** @@ -88,7 +107,7 @@ public function delete($name) { * @throws \Drupal\Core\Config\StorageException */ public function rename($name, $new_name) { - throw new StorageException('Rename operation is not allowed during install.'); + throw new StorageException('Rename operation is not allowed.'); } /** @@ -169,7 +188,7 @@ public function getComponentNames($type, array $list) { * The configuration folder name for this component. */ protected function getComponentFolder($type, $name) { - return drupal_get_path($type, $name) . '/config'; + return drupal_get_path($type, $name) . '/' . $this->directory; } /** @@ -178,7 +197,14 @@ protected function getComponentFolder($type, $name) { * @throws \Drupal\Core\Config\StorageException */ public function deleteAll($prefix = '') { - throw new StorageException('Delete operation is not allowed during install.'); + throw new StorageException('Delete operation is not allowed.'); + } + + /** + * Resets the static cache. + */ + public function reset() { + $this->folders = NULL; } } diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaStorage.php b/core/lib/Drupal/Core/Config/Schema/SchemaStorage.php deleted file mode 100644 index b58d1f6..0000000 --- a/core/lib/Drupal/Core/Config/Schema/SchemaStorage.php +++ /dev/null @@ -1,59 +0,0 @@ -getAllFolders()); - } - - /** - * Overrides \Drupal\Core\Config\InstallStorage::getComponentFolder(). - */ - protected function getComponentFolder($type, $name) { - return drupal_get_path($type, $name) . '/config/schema'; - } - - /** - * Overrides \Drupal\Core\Config\InstallStorage::write(). - * - * @throws \Drupal\Core\Config\StorageException - */ - public function write($name, array $data) { - throw new StorageException('Write operation is not allowed for config schema storage.'); - } - - /** - * Overrides \Drupal\Core\Config\InstallStorage::delete(). - * - * @throws \Drupal\Core\Config\StorageException - */ - public function delete($name) { - throw new StorageException('Delete operation is not allowed for config schema storage.'); - } - - /** - * Overrides \Drupal\Core\Config\InstallStorage::rename(). - * - * @throws \Drupal\Core\Config\StorageException - */ - public function rename($name, $new_name) { - throw new StorageException('Rename operation is not allowed for config schema storage.'); - } - -} diff --git a/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php index b7424f3..aa5b950 100644 --- a/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php @@ -8,7 +8,6 @@ namespace Drupal\config\Tests; use Drupal\config_test\TestInstallStorage; -use Drupal\config_test\TestSchemaStorage; use Drupal\Core\Config\Schema\Property; use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\TypedData\Type\BooleanInterface; @@ -70,7 +69,7 @@ public function testDefaultConfig() { // every module, profile and theme. $typed_config = new TypedConfigManager( \Drupal::service('config.storage'), - new TestSchemaStorage(), + new TestInstallStorage('config/schema'), \Drupal::service('cache.config') ); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/TestSchemaStorage.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/TestSchemaStorage.php deleted file mode 100644 index dd782a9..0000000 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/TestSchemaStorage.php +++ /dev/null @@ -1,44 +0,0 @@ -folders)) { - $this->folders = $this->getComponentNames('core', array('core')); - // @todo Refactor getComponentNames() to use the extension list directly. - $listing = new ExtensionDiscovery(); - $listing->setProfileDirectories(array()); - $this->folders += $this->getComponentNames('profile', array_keys($listing->scan('profile'))); - $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module'))); - $this->folders += $this->getComponentNames('theme', array_keys($listing->scan('theme'))); - } - return $this->folders; - } - -} diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigManagerTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigManagerTest.php index 453743c..bdde87f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigManagerTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigManagerTest.php @@ -40,18 +40,13 @@ public static function getInfo() { */ public function testHasTranslation() { $this->installConfig(array('locale_test')); - $locale_config_manager = new LocaleConfigManager( - $this->container->get('config.storage'), - $this->container->get('config.storage.schema'), - $this->container->get('config.storage.installer'), - $this->container->get('locale.storage'), - $this->container->get('cache.config'), - $this->container->get('config.factory'), - $this->container->get('language_manager') - ); + $locale_config_manager = \Drupal::service('locale.config.typed'); $language = new Language(array('id' => 'de')); - $this->assertFalse($locale_config_manager->hasTranslation('locale_test.no_translation', $language), 'There is no translation for locale_test.no_translation configuration.'); - $this->assertTrue($locale_config_manager->hasTranslation('locale_test.translation', $language), 'There is a translation for locale_test.translation configuration.'); + $result = $locale_config_manager->hasTranslation('locale_test.no_translation', $language); + $this->assertFalse($result, 'There is no translation for locale_test.no_translation configuration.'); + + $result = $locale_config_manager->hasTranslation('locale_test.translation', $language); + $this->assertTrue($result, 'There is a translation for locale_test.translation configuration.'); } }