StorageTransformEvent example

    if (!$this->requestLock->acquire(self::LOCK_NAME)) {
      $this->requestLock->wait(self::LOCK_NAME);
      if (!$this->requestLock->acquire(self::LOCK_NAME)) {
        throw new StorageTransformerException("Cannot acquire config import transformer lock.");
      }
    }

    // Copy the sync configuration to the created mutable storage.     self::replaceStorageContents($storage$mutable);

    // Dispatch the event so that event listeners can alter the configuration.     $this->eventDispatcher->dispatch(new StorageTransformEvent($mutable), ConfigEvents::STORAGE_TRANSFORM_IMPORT);

    // Return the storage with the altered configuration.     return $mutable;
  }

}
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(new StorageTransformEvent($this->storage), ConfigEvents::STORAGE_TRANSFORM_EXPORT);

    return new ReadOnlyStorage($this->storage);
  }

}
Home | Imprint | This part of the site doesn't use cookies.