1<?php 2 3namespace Drupal\Core\Config; 4 5use Drupal\Core\Site\Settings; 6 7/** 8 * Provides a factory for creating config file storage objects. 9 */ 10class FileStorageFactory { 11 12 /** 13 * Returns a FileStorage object working with the active config directory. 14 * 15 * @return \Drupal\Core\Config\FileStorage FileStorage 16 * 17 * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Drupal core 18 * no longer creates an active directory. 19 */ 20 public static function getActive() { 21 return new FileStorage(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY)); 22 } 23 24 /** 25 * Returns a FileStorage object working with the sync config directory. 26 * 27 * @return \Drupal\Core\Config\FileStorage FileStorage 28 * 29 * @throws \Exception 30 * In case the sync directory does not exist or is not defined in 31 * $settings['config_sync_directory']. 32 */ 33 public static function getSync() { 34 $directory = Settings::get('config_sync_directory', FALSE); 35 if ($directory === FALSE) { 36 // @todo: throw a more specific exception. 37 // @see https://www.drupal.org/node/2696103 38 throw new \Exception('The config sync directory is not defined in $settings["config_sync_directory"]'); 39 } 40 return new FileStorage($directory); 41 } 42 43} 44