array( * 'connection' => 'default', * 'read' => TRUE, * 'write' => TRUE, * ), * 'Drupal\Core\Config\FileStorage' => array( * 'directory' => 'sites/default/files/config', * 'read' => TRUE, * 'write' => FALSE, * ), * ) * @endcode * * @todo $this should really know about $name and make it publicly accessible. */ public function __construct($storages) { $this->storages = $storages; } public function load($name) { $storage = $this->findStorage('read', $name); if (empty($this->configObjects[$name])) { $this->configObjects[$name] = new ConfigObject($name, $this->storages[$storage]); } return $this->configObjects[$name]; } public function save($name, $data) { // Some logic to decide which storage to write to... $storage = $this->findStorage('write', $name); $this->storages[$storage]->write($name, $data); } public function delete($name) { // Some logic to decide which storage to write to... $storage = $this->findStorage('write', $name); $this->storage->delete($name); } public function findStorage($op, $name) { foreach ($this->storages as $class => $storage_config) { // Take the first storage that allows $op. if (!empty($storage_config[$op])) { break; } } if (!isset($this->storageInstances[$class])) { $this->storageInstances[$class] = new $class($storage_config); } return $this->storageInstances[$class]; } /** * More site-level stuff here, like config sync... */ }