function FileStorageFactory::getSync

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/FileStorageFactory.php \Drupal\Core\Config\FileStorageFactory::getSync()
  2. 8.9.x core/lib/Drupal/Core/Config/FileStorageFactory.php \Drupal\Core\Config\FileStorageFactory::getSync()
  3. 10 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

\Drupal\Core\Config\ConfigDirectoryNotDefinedException 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

File

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

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) {
        throw new ConfigDirectoryNotDefinedException('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.