function SyncFactory::get

Same name and namespace in other branches
  1. main core/lib/Drupal/Core/Config/SyncFactory.php \Drupal\Core\Config\SyncFactory::get()

Gets a StorageInterface object working with the sync config directory.

The FileStorage object is wrapped in an AutoloadingStorage object to ensure we can read configuration from new extensions.

Return value

\Drupal\Core\Config\StorageInterface The storage object for working with the config sync directory.

Throws

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

File

core/lib/Drupal/Core/Config/SyncFactory.php, line 43

Class

SyncFactory
The factory class to create the config.storage.sync service.

Namespace

Drupal\Core\Config

Code

public function get() : StorageInterface {
  $directory = $this->settings
    ->get('config_sync_directory', FALSE);
  if ($directory === FALSE) {
    throw new ConfigDirectoryNotDefinedException('The config sync directory is not defined in $settings["config_sync_directory"]');
  }
  $storage = new FileStorage($directory);
  return $this->wrapStorageWithAutoloadingStorage($storage);
}

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