diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index fc1de17..4c28ced 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -478,6 +478,25 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) { } /** + * Returns the path of the configuration directory. + * + * @return string + * The configuration directory path. + */ +function config_get_config_directory() { + global $config_directory_name; + + if ($test_prefix = drupal_valid_test_ua()) { + // @see Drupal\simpletest\WebTestBase::setUp() + $path = conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/config'; + } + else { + $path = conf_path() . '/files/' . $config_directory_name; + } + return $path; +} + +/** * Sets appropriate server variables needed for command line scripts to work. * * This function can be called by command line scripts before bootstrapping diff --git a/core/includes/config.inc b/core/includes/config.inc index ce8f659..0771d60 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -12,25 +12,6 @@ use Drupal\Core\Config\StorageInterface; */ /** - * Gets the randomly generated config directory name. - * - * @return - * The directory name. - */ -function config_get_config_directory() { - global $config_directory_name; - - if ($test_prefix = drupal_valid_test_ua()) { - // @see Drupal\simpletest\WebTestBase::setUp() - $path = conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/config'; - } - else { - $path = conf_path() . '/files/' . $config_directory_name; - } - return $path; -} - -/** * Installs the default configuration of a given module. * * @param diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 4edbc2a..7eb2d6c 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -22,20 +22,21 @@ class Config { protected $data = array(); /** - * The wrapping storage manager object. + * The injected storage dispatcher object. * - * @var Drupal\Core\Config\StorageManager + * @var Drupal\Core\Config\StorageDispatcher */ - protected $storageManager; + protected $storageDispatcher; /** * Constructs a configuration object. * - * @param Drupal\Core\Config\StorageManager $storageManager - * The wrapping configuration manager object. + * @param Drupal\Core\Config\StorageDispatcher $storageDispatcher + * A storage dispatcher object to use for reading and writing the + * configuration data. */ - public function __construct(StorageManager $storageManager) { - $this->storageManager = $storageManager; + public function __construct(StorageDispatcher $storageDispatcher) { + $this->storageDispatcher = $storageDispatcher; } /** @@ -203,7 +204,7 @@ class Config { */ public function load() { $this->setData(array()); - $data = $this->storageManager->selectStorage('read', $this->name)->read($this->name); + $data = $this->storageDispatcher->selectStorage('read', $this->name)->read($this->name); if ($data !== FALSE) { $this->setData($data); } @@ -215,7 +216,7 @@ class Config { */ public function save() { $this->sortByKey($this->data); - $this->storageManager->selectStorage('write', $this->name)->write($this->name, $this->data); + $this->storageDispatcher->selectStorage('write', $this->name)->write($this->name, $this->data); return $this; } @@ -244,7 +245,7 @@ class Config { */ public function delete() { $this->data = array(); - $this->storageManager->selectStorage('write', $this->name)->delete($this->name); + $this->storageDispatcher->selectStorage('write', $this->name)->delete($this->name); return $this; } } diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index d749281..fe77bad 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -12,24 +12,23 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Defines the configuration object factory. * - * The configuration object factory instantiates a configuration object for each - * configuration object name that is accessed and returns the configuration - * object to callers. + * The configuration object factory instantiates a Config object for each + * configuration object name that is accessed and returns it to callers. * - * Each configuration object is wrapped by a configuration manager object, which - * is used to determine the storage controller to use for reading and writing - * the configuration object data. + * Each configuration object gets a storage dispatcher object injected, which + * determines the storage controller to use for reading and writing the + * configuration data. * * @see Drupal\Core\Config\Config */ class ConfigFactory { protected $containerClass; - protected $storageManager; + protected $storageDispatcher; - public function __construct($container_class, StorageManager $storage_manager) { + public function __construct($container_class, StorageDispatcher $storage_dispatcher) { $this->containerClass = $container_class; - $this->storageManager = $storage_manager; + $this->storageDispatcher = $storage_dispatcher; } /** @@ -60,7 +59,7 @@ class ConfigFactory { // @todo The decrease of CPU time is interesting, since that means that // ContainerBuilder involves plenty of function calls (which are known to // be slow in PHP). - $config = new $this->containerClass($this->storageManager); + $config = new $this->containerClass($this->storageDispatcher); return $config->setName($name); } } diff --git a/core/lib/Drupal/Core/Config/StorageManager.php b/core/lib/Drupal/Core/Config/StorageDispatcher.php similarity index 73% rename from core/lib/Drupal/Core/Config/StorageManager.php rename to core/lib/Drupal/Core/Config/StorageDispatcher.php index 82afe01..9e14c73 100644 --- a/core/lib/Drupal/Core/Config/StorageManager.php +++ b/core/lib/Drupal/Core/Config/StorageDispatcher.php @@ -3,24 +3,24 @@ namespace Drupal\Core\Config; /** - * Manages configuration storage controllers. + * Dispatches read/write operations to storage controllers. * - * A high-level storage manager that determines which storage out of multiple - * is configured and allowed to handle a particular configuration object, - * depending on the read/write operation being performed. + * The storage dispatcher determines which storage out of multiple is configured + * and allowed to handle a particular configuration object, depending on the + * read/write operation being performed. * * The information about available storage controllers and their configuration * options is passed once into the constructor and normally should not change * within a single request or context. Special use-cases, such as import and - * export operations, should instantiate a custom configuration manager tailored - * to their application needs. + * export operations, should instantiate a custom storage dispatcher tailored + * to their specific needs. * - * The configuration manager instantiates storage controllers on demand, and - * only once per storage. + * The storage dispatcher instantiates storage controllers on demand, and only + * once per storage. * * @see Drupal\Core\Config\StorageInterface */ -class StorageManager { +class StorageDispatcher { /** * Information about available storage controllers. @@ -39,11 +39,11 @@ class StorageManager { protected $storageInstances; /** - * Constructs the storage manager object. + * Constructs the storage dispatcher object. * * @param array $storage_info * An associative array defining the storage controllers to use and any - * required configuration for them; e.g.: + * required configuration options for them; e.g.: * @code * array( * 'Drupal\Core\Config\DatabaseStorage' => array( @@ -66,15 +66,17 @@ class StorageManager { /** * Returns a storage controller to use for a given operation. * - * Handles the core functionality of the configuration manager by determining - * which storage can handle a particular configuration object, depending on - * the operation being performed. + * Handles the core functionality of the storage dispatcher by determining + * which storage can handle a particular storage access operation and + * configuration object. * * @param string $access_operation * The operation access level; either 'read' or 'write'. Use 'write' both * for saving and deleting configuration. * @param string $name * The name of the configuration object that is operated on. + * + * @todo Allow write operations to write to multiple storages. */ public function selectStorage($access_operation, $name) { // Determine the appropriate storage controller to use. diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index 706960d..98a9bd3 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -30,8 +30,7 @@ class ContainerBuilder extends BaseContainerBuilder { // Register the default language content. $this->register(LANGUAGE_TYPE_CONTENT, 'Drupal\\Core\\Language\\Language'); - // Register configuration system manager. - $this->setParameter('config.storage.manager', 'Drupal\Core\Config\StorageManager'); + // Register configuration storage dispatcher. $this->setParameter('config.storage.info', array( 'Drupal\Core\Config\DatabaseStorage' => array( 'target' => 'default', @@ -44,14 +43,12 @@ class ContainerBuilder extends BaseContainerBuilder { 'write' => FALSE, ), )); - $this->register('config.storage.manager', '%config.storage.manager%') + $this->register('config.storage.dispatcher', 'Drupal\Core\Config\StorageDispatcher') ->addArgument('%config.storage.info%'); - // Register configuration system. - $this->setParameter('config.factory', 'Drupal\Core\Config\ConfigFactory'); - $this->setParameter('config.container', 'Drupal\Core\Config\Config'); - $this->register('config.factory', '%config.factory%') - ->addArgument('%config.container%') - ->addArgument(new Reference('config.storage.manager')); + // Register configuration object factory. + $this->register('config.factory', 'Drupal\Core\Config\ConfigFactory') + ->addArgument('Drupal\Core\Config\Config') + ->addArgument(new Reference('config.storage.dispatcher')); } }