diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 7f9df9c..d33cff5 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2436,16 +2436,7 @@ function drupal_container(Container $reset = NULL) { $container = new ContainerBuilder(); // Register configuration storage class and options. - // @todo The active store and its options need to be configurable. - // Use either global $conf (recursion warning) or global $config, or a - // bootstrap configuration *file* to allow to set/override this very - // lowest of low level configuration. - $container->setParameter('config.storage.options', array( - 'connection' => 'default', - 'target' => 'default', - )); - $container->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') - ->addArgument('%config.storage.options%'); + $container->register('config.storage', 'Drupal\Core\Config\DatabaseStorage'); $container->register('config.subscriber.globalconf', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber'); $container->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher') diff --git a/core/includes/config.inc b/core/includes/config.inc index 369a0d1..cbd3fd5 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(); 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/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index ad8c155..51d9063 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -23,24 +23,20 @@ class DatabaseStorage implements StorageInterface { * * @var array */ - protected $options; + protected $target; /** * Implements Drupal\Core\Config\StorageInterface::__construct(). */ - public function __construct(array $options = array()) { - $options += array( - 'connection' => 'default', - 'target' => 'default', - ); - $this->options = $options; + public function __construct($target = 'default') { + $this->target = $target; } /** * Returns the database connection to use. */ protected function getConnection() { - return Database::getConnection($this->options['target'], $this->options['connection']); + return Database::getConnection($this->target); } /** 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/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 2c5d180..cc0d32b 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -43,14 +43,6 @@ class CoreBundle extends Bundle $container->register('language_manager', 'Drupal\Core\Language\LanguageManager') ->addArgument(new Reference('request')) ->setScope('request'); - $container->register('database', 'Drupal\Core\Database\Connection') - ->setFactoryClass('Drupal\Core\Database\Database') - ->setFactoryMethod('getConnection') - ->addArgument('default'); - $container->register('database.slave', 'Drupal\Core\Database\Connection') - ->setFactoryClass('Drupal\Core\Database\Database') - ->setFactoryMethod('getConnection') - ->addArgument('slave'); // @todo Replace below lines with the commented out block below it when it's // performant to do so: http://drupal.org/node/1706064. diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php index 2e1599f..f50fa64 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/DatabaseStorageTest.php @@ -24,7 +24,7 @@ class DatabaseStorageTest extends ConfigStorageTestBase { function setUp() { parent::setUp(); $this->storage = new DatabaseStorage(); - $this->invalidStorage = new DatabaseStorage(array('connection' => 'invalid')); + $this->invalidStorage = new DatabaseStorage('invalid'); } protected function read($name) { 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.