3 namespace Drupal\Core\Config;
5 use Drupal\Core\Database\Database;
6 use Drupal\Core\Site\Settings;
9 * Defines a factory for retrieving the config storage used pre-kernel.
11 class BootstrapConfigStorageFactory {
14 * Returns a configuration storage implementation.
16 * @param $class_loader
17 * The class loader. Normally Composer's ClassLoader, as included by the
18 * front controller, but may also be decorated; e.g.,
19 * \Symfony\Component\ClassLoader\ApcClassLoader.
21 * @return \Drupal\Core\Config\StorageInterface
22 * A configuration storage implementation.
24 public static function get($class_loader = NULL) {
25 $bootstrap_config_storage = Settings::get('bootstrap_config_storage');
26 $storage_backend = FALSE;
27 if (!empty($bootstrap_config_storage) && is_callable($bootstrap_config_storage)) {
28 $storage_backend = call_user_func($bootstrap_config_storage, $class_loader);
30 // Fallback to the DatabaseStorage.
31 return $storage_backend ?: self::getDatabaseStorage();
35 * Returns a Database configuration storage implementation.
37 * @return \Drupal\Core\Config\DatabaseStorage
39 public static function getDatabaseStorage() {
40 return new DatabaseStorage(Database::getConnection(), 'config');
44 * Returns a File-based configuration storage implementation.
46 * If there is no active configuration directory calling this method will
49 * @return \Drupal\Core\Config\FileStorage
51 * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core
52 * no longer creates an active directory.
56 public static function getFileStorage() {
57 return new FileStorage(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));