IcingaObjectResolver: clone filter, use helper
This commit is contained in:
parent
15b52a323c
commit
04557aad1c
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Resolver;
|
||||||
|
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Module\Director\Data\AssignFilterHelper;
|
||||||
use Icinga\Module\Director\Objects\DynamicApplyMatches;
|
use Icinga\Module\Director\Objects\DynamicApplyMatches;
|
||||||
use Zend_Db_Adapter_Abstract as ZfDB;
|
use Zend_Db_Adapter_Abstract as ZfDB;
|
||||||
|
|
||||||
|
@ -119,14 +120,17 @@ class IcingaObjectResolver
|
||||||
|
|
||||||
public function fetchObjectsMatchingFilter(Filter $filter)
|
public function fetchObjectsMatchingFilter(Filter $filter)
|
||||||
{
|
{
|
||||||
|
$filter = clone($filter);
|
||||||
DynamicApplyMatches::setType($this->getType());
|
DynamicApplyMatches::setType($this->getType());
|
||||||
DynamicApplyMatches::fixFilterColumns($filter);
|
DynamicApplyMatches::fixFilterColumns($filter);
|
||||||
|
$helper = new AssignFilterHelper($filter);
|
||||||
$objects = [];
|
$objects = [];
|
||||||
$allVars = $this->fetchNonTemplateVars();
|
$allVars = $this->fetchNonTemplateVars();
|
||||||
foreach ($this->fetchPlainObjects($this->baseTable, 'object') as $object) {
|
foreach ($this->fetchPlainObjects($this->baseTable, 'object') as $object) {
|
||||||
$id = $object->id; // id will be stripped
|
$id = $object->id; // id will be stripped
|
||||||
if ($filter->matches($object)) {
|
$object = $this->enrichObject($object, $allVars);
|
||||||
$objects[$id] = $this->enrichObject($object, $allVars);
|
if ($helper->matches($object)) {
|
||||||
|
$objects[$id] = $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ use Icinga\Module\Director\Resolver\IcingaHostObjectResolver;
|
||||||
|
|
||||||
class IcingaHostsMatchingFilterTable extends QueryBasedTable
|
class IcingaHostsMatchingFilterTable extends QueryBasedTable
|
||||||
{
|
{
|
||||||
protected $filter;
|
|
||||||
|
|
||||||
protected $searchColumns = [
|
protected $searchColumns = [
|
||||||
'object_name',
|
'object_name',
|
||||||
];
|
];
|
||||||
|
@ -25,8 +23,6 @@ class IcingaHostsMatchingFilterTable extends QueryBasedTable
|
||||||
public static function load(Filter $filter, Db $db)
|
public static function load(Filter $filter, Db $db)
|
||||||
{
|
{
|
||||||
$table = new static();
|
$table = new static();
|
||||||
$table->filter = $filter;
|
|
||||||
|
|
||||||
$table->dataSource = new ArrayDatasource(
|
$table->dataSource = new ArrayDatasource(
|
||||||
(new IcingaHostObjectResolver($db->getDbAdapter()))
|
(new IcingaHostObjectResolver($db->getDbAdapter()))
|
||||||
->fetchObjectsMatchingFilter($filter)
|
->fetchObjectsMatchingFilter($filter)
|
||||||
|
|
Loading…
Reference in New Issue