function FileStorageFactory::getSync

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

Returns a FileStorage object working with the sync config directory.

Return value

\Drupal\Core\Config\FileStorage FileStorage

Throws

\Exception In case the sync directory does not exist or is not defined in $settings['config_sync_directory'].

1 call to FileStorageFactory::getSync()
FileStorageFactoryTest::testGetSync in core/tests/Drupal/KernelTests/Core/Config/FileStorageFactoryTest.php
@covers ::getSync
1 string reference to 'FileStorageFactory::getSync'
core.services.yml in core/core.services.yml
core/core.services.yml

File

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

Class

FileStorageFactory
Provides a factory for creating config file storage objects.

Namespace

Drupal\Core\Config

Code

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);
}

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