diff --git a/framework/core/src/Filter/AbstractFilterer.php b/framework/core/src/Filter/AbstractFilterer.php index 736568901..5f07fdbbb 100644 --- a/framework/core/src/Filter/AbstractFilterer.php +++ b/framework/core/src/Filter/AbstractFilterer.php @@ -62,6 +62,7 @@ abstract class AbstractFilterer $filterKey = substr($filterKey, 1); } foreach (Arr::get($this->filters, $filterKey, []) as $filter) { + $filterState->addActiveFilter($filter); $filter->filter($filterState, $filterValue, $negate); } } diff --git a/framework/core/src/Filter/FilterState.php b/framework/core/src/Filter/FilterState.php index b9e22611e..5597964da 100644 --- a/framework/core/src/Filter/FilterState.php +++ b/framework/core/src/Filter/FilterState.php @@ -13,4 +13,29 @@ use Flarum\Query\AbstractQueryState; class FilterState extends AbstractQueryState { + /** + * @var FilterInterface[] + */ + protected $activeFilters = []; + + /** + * Get a list of the filters that are active. + * + * @return FilterInterface[] + */ + public function getActiveFilters() + { + return $this->activeFilters; + } + + /** + * Add a filter as being active. + * + * @param FilterInterface $filter + * @return void + */ + public function addActiveFilter(FilterInterface $filter) + { + $this->activeFilters[] = $filter; + } }