Commit 05855047 authored by tstoeckler's avatar tstoeckler Committed by bircher

Issue #2925084 by tstoeckler: FilteredStorage::createCollection() needs to set...

Issue #2925084 by tstoeckler: FilteredStorage::createCollection() needs to set the correct source and filtered storages on filters
parent a1b2b1d8
......@@ -202,14 +202,23 @@ class FilteredStorage implements FilteredStorageInterface {
*/
public function createCollection($collection) {
$filters = [];
foreach ($this->filters as $filter) {
foreach ($this->filters as $key => $filter) {
$filter = $filter->filterCreateCollection($collection);
if ($filter) {
$filters[] = $filter;
$filters[$key] = $filter;
}
}
$storage = $this->storage->createCollection($collection);
$filtered = new static($storage, $filters);
// Set the storage to all the filters.
foreach ($filters as $filter) {
$filter->setSourceStorage(new ReadOnlyStorage($storage));
$filter->setFilteredStorage($filtered);
}
return new static($this->storage->createCollection($collection), $filters);
return $filtered;
}
/**
......
......@@ -189,7 +189,8 @@ interface StorageFilterInterface {
*
* @return \Drupal\config_filter\Config\StorageFilterInterface|null
* Return a filter that should participate in the collection. This allows
* filters to act on different collections.
* filters to act on different collections. Note that a new instance of the
* filter should be created rather than returning $this directly.
*/
public function filterCreateCollection($collection);
......
......@@ -125,7 +125,7 @@ abstract class ConfigFilterBase extends PluginBase implements ConfigFilterInterf
* {@inheritdoc}
*/
public function filterCreateCollection($collection) {
return $this;
return clone $this;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment