class StorageWrapper

  1. 8.0.x lib/Drush/Config/StorageWrapper.php StorageWrapper
  2. master lib/Drush/Config/StorageWrapper.php StorageWrapper

Namespace

Drush\Config

Hierarchy

Expanded class hierarchy of StorageWrapper

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
StorageWrapper::$filters protected property
StorageWrapper::$storage protected property The storage container that we are wrapping.
StorageWrapper::createCollection public function
StorageWrapper::decode public function
StorageWrapper::delete public function
StorageWrapper::deleteAll public function
StorageWrapper::encode public function
StorageWrapper::exists public function
StorageWrapper::getAllCollectionNames public function
StorageWrapper::getCollectionName public function
StorageWrapper::listAll public function
StorageWrapper::read public function
StorageWrapper::readMultiple public function
StorageWrapper::rename public function
StorageWrapper::write public function
StorageWrapper::__construct function Create a StorageWrapper with some storage and a filter.

File

lib/Drush/Config/StorageWrapper.php, line 12
Definition of Drush\Config\StorageWrapper.

View source
class StorageWrapper implements StorageInterface {

  /**
   * The storage container that we are wrapping.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $storage;
  protected $filters;

  /**
   * Create a StorageWrapper with some storage and a filter.
   */
  function __construct($storage, $filterOrFilters) {
    $this->storage = $storage;
    $this->filters = is_array($filterOrFilters) ? $filterOrFilters : array($filterOrFilters);
  }

  /**
   * {@inheritdoc}
   */
  public function exists($name) {
    return $this->storage->exists($name);
  }

  /**
   * {@inheritdoc}
   */
  public function read($name) {
    $data = $this->storage->read($name);

    foreach ($this->filters as $filter) {
      $data = $filter->filterRead($name, $data);
    }

    return $data;
  }

  /**
   * {@inheritdoc}
   */
  public function readMultiple(array $names) {
    $dataList = $this->storage->readMultiple($names);
    $result = array();

    foreach ($dataList as $name => $data) {
      foreach ($this->filters as $filter) {
        $data = $filter->filterRead($name, $data);
      }
      $result[$name] = $data;
    }

    return $result;
  }

  /**
   * {@inheritdoc}
   */
  public function write($name, array $data) {
    foreach ($this->filters as $filter) {
      $data = $filter->filterWrite($name, $data, $this->storage);
    }

    return $this->storage->write($name, $data);
  }

  /**
   * {@inheritdoc}
   */
  public function delete($name) {
    return $this->storage->delete($name);
  }

  /**
   * {@inheritdoc}
   */
  public function rename($name, $new_name) {
    return $this->storage->rename($name, $new_name);
  }

  /**
   * {@inheritdoc}
   */
  public function encode($data) {
    return $this->storage->encode($data);
  }

  /**
   * {@inheritdoc}
   */
  public function decode($raw) {
    return $this->storage->decode($raw);
  }

  /**
   * {@inheritdoc}
   */
  public function listAll($prefix = '') {
    return $this->storage->listAll($prefix);
  }

  /**
   * {@inheritdoc}
   */
  public function deleteAll($prefix = '') {
    return $this->storage->deleteAll($prefix);
  }

  /**
   * {@inheritdoc}
   */
  public function createCollection($collection) {
    return $this->storage->createCollection($collection);
  }

  /**
   * {@inheritdoc}
   */
  public function getAllCollectionNames() {
    return $this->storage->getAllCollectionNames();
  }

  /**
   * {@inheritdoc}
   */
  public function getCollectionName() {
    return $this->storage->getCollectionName();
  }

}
1 file declares its use of StorageWrapper
config.drush.inc in commands/core/config.drush.inc
Provides Configuration Management commands.