mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 02:10:09 +08:00
Provide active filters to filter state
This commit is contained in:
parent
99311188a2
commit
38dc12ef0d
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user