You are here

public function DistroStorageManager::getStorage in Config Distro 8

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

src/DistroStorageManager.php, line 83

Class

DistroStorageManager
The distro storage manager dispatches an event for the distro storage.

Namespace

Drupal\config_distro

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 distro transformer lock.");
    }
  }
  self::replaceStorageContents($this->active, $this->storage);
  $this->eventDispatcher
    ->dispatch(ConfigDistroEvents::TRANSFORM, new DistroStorageTransformEvent($this->storage));
  return new ReadOnlyStorage($this->storage);
}