diff --git a/core/includes/config.inc b/core/includes/config.inc index 369a0d1..abc64e7 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -24,7 +24,7 @@ use Drupal\Core\Config\StorageInterface; function config_install_default_config($type, $name) { $config_dir = drupal_get_path($type, $name) . '/config'; if (is_dir($config_dir)) { - $source_storage = new FileStorage(array('directory' => $config_dir)); + $source_storage = new FileStorage($config_dir); $target_storage = drupal_container()->get('config.storage'); $null_storage = new NullStorage(); @@ -137,7 +137,7 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto */ function config_import() { // Retrieve a list of differences between staging and the active store. - $source_storage = new FileStorage(array('directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY))); + $source_storage = new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); $target_storage = drupal_container()->get('config.storage'); $config_changes = config_sync_get_changes($source_storage, $target_storage); @@ -219,7 +219,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou function config_export() { // Retrieve a list of differences between the active store and staging. $source_storage = drupal_container()->get('config.storage'); - $target_storage = new FileStorage(array('directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY))); + $target_storage = new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); $config_changes = config_sync_get_changes($source_storage, $target_storage); if (empty($config_changes)) { diff --git a/core/includes/update.inc b/core/includes/update.inc index 5582bb4..9dd8456 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1056,7 +1056,7 @@ function update_variables_to_config($config_name, array $variable_map) { $module = strtok($config_name, '.'); // Load and set default configuration values. - $file = new FileStorage(array('directory' => drupal_get_path('module', $module) . '/config')); + $file = new FileStorage(drupal_get_path('module', $module) . '/config'); if (!$file->exists($config_name)) { throw new ConfigException("Default configuration file $config_name for $module extension not found but is required to exist."); } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index d96af7e..c068ab8 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -26,11 +26,11 @@ class FileStorage implements StorageInterface { /** * Implements Drupal\Core\Config\StorageInterface::__construct(). */ - public function __construct(array $options = array()) { - if (!isset($options['directory'])) { - $options['directory'] = config_get_config_directory(); + public function __construct($directory = '') { + if (empty($directory)) { + $directory = config_get_config_directory(); } - $this->options = $options; + $this->directory = $directory; } /** @@ -40,7 +40,7 @@ class FileStorage implements StorageInterface { * The path to the configuration file. */ public function getFilePath($name) { - return $this->options['directory'] . '/' . $name . '.' . self::getFileExtension(); + return $this->directory . '/' . $name . '.' . self::getFileExtension(); } /** @@ -99,8 +99,8 @@ class FileStorage implements StorageInterface { */ public function delete($name) { if (!$this->exists($name)) { - if (!file_exists($this->options['directory'])) { - throw new StorageException($this->options['directory'] . '/ not found.'); + if (!file_exists($this->directory)) { + throw new StorageException($this->directory . '/ not found.'); } return FALSE; } @@ -149,11 +149,11 @@ class FileStorage implements StorageInterface { public function listAll($prefix = '') { // glob() silently ignores the error of a non-existing search directory, // even with the GLOB_ERR flag. - if (!file_exists($this->options['directory'])) { - throw new StorageException($this->options['directory'] . '/ not found.'); + if (!file_exists($this->directory)) { + throw new StorageException($this->directory . '/ not found.'); } $extension = '.' . self::getFileExtension(); - $files = glob($this->options['directory'] . '/' . $prefix . '*' . $extension); + $files = glob($this->directory . '/' . $prefix . '*' . $extension); $clean_name = function ($value) use ($extension) { return basename($value, $extension); }; diff --git a/core/lib/Drupal/Core/Config/NullStorage.php b/core/lib/Drupal/Core/Config/NullStorage.php index ea21be1..09ae3e9 100644 --- a/core/lib/Drupal/Core/Config/NullStorage.php +++ b/core/lib/Drupal/Core/Config/NullStorage.php @@ -22,11 +22,6 @@ namespace Drupal\Core\Config; * This also can be used for testing purposes. */ class NullStorage implements StorageInterface { - /** - * Implements Drupal\Core\Config\StorageInterface::__construct(). - */ - public function __construct(array $options = array()) { - } /** * Implements Drupal\Core\Config\StorageInterface::read(). diff --git a/core/lib/Drupal/Core/Config/StorageInterface.php b/core/lib/Drupal/Core/Config/StorageInterface.php index a466538..2d3dcda 100644 --- a/core/lib/Drupal/Core/Config/StorageInterface.php +++ b/core/lib/Drupal/Core/Config/StorageInterface.php @@ -16,15 +16,6 @@ namespace Drupal\Core\Config; interface StorageInterface { /** - * Constructs the storage controller. - * - * @param array $options - * An associative array containing configuration options specific to the - * storage controller. - */ - public function __construct(array $options = array()); - - /** * Reads configuration data from the storage. * * @param string $name diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php index 0c1fe68..cbdf2dc 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php @@ -65,7 +65,7 @@ class ConfigImportTest extends WebTestBase { $name = 'config_test.system'; $dynamic_name = 'config_test.dynamic.default'; $active_storage = new DatabaseStorage(); - $staging_storage = new FileStorage(array('directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY))); + $staging_storage = new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); // Verify the default configuration values exist. $config = config($name); @@ -107,7 +107,7 @@ class ConfigImportTest extends WebTestBase { function testNew() { $name = 'config_test.new'; $dynamic_name = 'config_test.dynamic.new'; - $staging_storage = new FileStorage(array('directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY))); + $staging_storage = new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); // Export. config_export(); @@ -153,7 +153,7 @@ class ConfigImportTest extends WebTestBase { function testUpdated() { $name = 'config_test.system'; $dynamic_name = 'config_test.dynamic.default'; - $staging_storage = new FileStorage(array('directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY))); + $staging_storage = new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); // Export. config_export(); diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php index 0fd2ba4..3c617c8 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php @@ -25,7 +25,7 @@ class FileStorageTest extends ConfigStorageTestBase { function setUp() { parent::setUp(); $this->storage = new FileStorage(); - $this->invalidStorage = new FileStorage(array('directory' => $this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting')); + $this->invalidStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY] . '/nonexisting'); // FileStorage::listAll() requires other configuration data to exist. $this->storage->write('system.performance', config('system.performance')->get()); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index 1698737..36f4be3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -99,7 +99,7 @@ abstract class ModuleTestBase extends WebTestBase { if (!is_dir($module_config_dir)) { return; } - $module_file_storage = new FileStorage(array('directory' => $module_config_dir)); + $module_file_storage = new FileStorage($module_config_dir); $names = $module_file_storage->listAll(); // Verify that the config directory is not empty.