5 * Definition of Drush\Config\StorageWrapper.
8 namespace Drush\Config;
10 use Drupal\Core\Config\StorageInterface;
12 class StorageWrapper implements StorageInterface {
15 * The storage container that we are wrapping.
17 * @var \Drupal\Core\Config\StorageInterface
23 * Create a StorageWrapper with some storage and a filter.
25 function __construct($storage, $filterOrFilters) {
26 $this->storage = $storage;
27 $this->filters = is_array($filterOrFilters) ? $filterOrFilters : array($filterOrFilters);
33 public function exists($name) {
34 return $this->storage->exists($name);
40 public function read($name) {
41 $data = $this->storage->read($name);
43 foreach ($this->filters as $filter) {
44 $data = $filter->filterRead($name, $data);
53 public function readMultiple(array $names) {
54 $dataList = $this->storage->readMultiple($names);
57 foreach ($dataList as $name => $data) {
58 foreach ($this->filters as $filter) {
59 $data = $filter->filterRead($name, $data);
61 $result[$name] = $data;
70 public function write($name, array $data) {
71 foreach ($this->filters as $filter) {
72 $data = $filter->filterWrite($name, $data, $this->storage);
75 return $this->storage->write($name, $data);
81 public function delete($name) {
82 return $this->storage->delete($name);
88 public function rename($name, $new_name) {
89 return $this->storage->rename($name, $new_name);
95 public function encode($data) {
96 return $this->storage->encode($data);
102 public function decode($raw) {
103 return $this->storage->decode($raw);
109 public function listAll($prefix = '') {
110 return $this->storage->listAll($prefix);
116 public function deleteAll($prefix = '') {
117 return $this->storage->deleteAll($prefix);
123 public function createCollection($collection) {
124 return $this->storage->createCollection($collection);
130 public function getAllCollectionNames() {
131 return $this->storage->getAllCollectionNames();
137 public function getCollectionName() {
138 return $this->storage->getCollectionName();