class FileStorageFactory

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/FileStorageFactory.php \Drupal\Core\Config\FileStorageFactory
  2. 10 core/lib/Drupal/Core/Config/FileStorageFactory.php \Drupal\Core\Config\FileStorageFactory
  3. 11.x core/lib/Drupal/Core/Config/FileStorageFactory.php \Drupal\Core\Config\FileStorageFactory

Provides a factory for creating config file storage objects.

Hierarchy

Expanded class hierarchy of FileStorageFactory

1 file declares its use of FileStorageFactory
FileStorageFactoryTest.php in core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php

File

core/lib/Drupal/Core/Config/FileStorageFactory.php, line 10

Namespace

Drupal\Core\Config
View source
class FileStorageFactory {
    
    /**
     * Returns a FileStorage object working with the active config directory.
     *
     * @return \Drupal\Core\Config\FileStorage FileStorage
     *
     * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Drupal core
     * no longer creates an active directory.
     */
    public static function getActive() {
        return new FileStorage(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
    }
    
    /**
     * Returns a FileStorage object working with the sync config directory.
     *
     * @return \Drupal\Core\Config\FileStorage FileStorage
     *
     * @throws \Exception
     *   In case the sync directory does not exist or is not defined in
     *   $settings['config_sync_directory'].
     */
    public static function getSync() {
        $directory = Settings::get('config_sync_directory', FALSE);
        if ($directory === FALSE) {
            // @todo: throw a more specific exception.
            // @see https://www.drupal.org/node/2696103
            throw new \Exception('The config sync directory is not defined in $settings["config_sync_directory"]');
        }
        return new FileStorage($directory);
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary
FileStorageFactory::getActive Deprecated public static function Returns a FileStorage object working with the active config directory.
FileStorageFactory::getSync public static function Returns a FileStorage object working with the sync config directory.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.