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