You are here

public function ExportStorageManager::getStorage in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Config/ExportStorageManager.php \Drupal\Core\Config\ExportStorageManager::getStorage()

Get the config storage.

Return value

\Drupal\Core\Config\StorageInterface The config storage.

Throws

\Drupal\Core\Config\StorageTransformerException Thrown when the lock could not be acquired.

Overrides StorageManagerInterface::getStorage

File

core/lib/Drupal/Core/Config/ExportStorageManager.php, line 77

Class

ExportStorageManager
The export storage manager dispatches an event for the export storage.

Namespace

Drupal\Core\Config

Code

public function getStorage() {

  // Acquire a lock for the request to assert that the storage does not change
  // when a concurrent request transforms the storage.
  if (!$this->lock
    ->acquire(self::LOCK_NAME)) {
    $this->lock
      ->wait(self::LOCK_NAME);
    if (!$this->lock
      ->acquire(self::LOCK_NAME)) {
      throw new StorageTransformerException("Cannot acquire config export transformer lock.");
    }
  }
  self::replaceStorageContents($this->active, $this->storage);
  $this->eventDispatcher
    ->dispatch(ConfigEvents::STORAGE_TRANSFORM_EXPORT, new StorageTransformEvent($this->storage));
  return new ReadOnlyStorage($this->storage);
}