ObjectList: Implement interface Filterable
Allows to use instances of it for Controller::applyRestriction(). refs #9009
This commit is contained in:
parent
ede8cc5e83
commit
a1e4e6e92b
|
@ -6,10 +6,11 @@ namespace Icinga\Module\Monitoring\Object;
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Countable;
|
use Countable;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Data\Filterable;
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
|
|
||||||
abstract class ObjectList implements Countable, IteratorAggregate
|
abstract class ObjectList implements Countable, IteratorAggregate, Filterable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -81,9 +82,29 @@ abstract class ObjectList implements Countable, IteratorAggregate
|
||||||
*/
|
*/
|
||||||
public function getFilter()
|
public function getFilter()
|
||||||
{
|
{
|
||||||
|
if ($this->filter === null) {
|
||||||
|
$this->filter = Filter::matchAny();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->filter;
|
return $this->filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function applyFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
$this->getFilter()->addFilter($filter);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
$this->getFilter()->addFilter($filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function where($condition, $value = null)
|
||||||
|
{
|
||||||
|
$this->getFilter()->addFilter(Filter::where($condition, $value));
|
||||||
|
}
|
||||||
|
|
||||||
abstract protected function fetchObjects();
|
abstract protected function fetchObjects();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue