HostApplyMatches: allow usage for single hosts

refs #13849
This commit is contained in:
Thomas Gelf 2017-01-02 10:15:35 +01:00
parent c9929f7b17
commit 0a9ed6ff39
1 changed files with 21 additions and 2 deletions

View File

@ -16,6 +16,22 @@ class HostApplyMatches
'name' => 'object_name'
);
protected $host;
protected $flatHost;
public static function prepare(IcingaHost $host)
{
return new static($host);
}
public function matchesFilter(Filter $filter)
{
$filter = clone($filter);
static::fixFilterColumns($filter);
return $filter->matches($this->flatHost);
}
/**
* @param Filter $filter
* @param Db $db
@ -116,7 +132,10 @@ class HostApplyMatches
}
}
protected function __construct()
protected function __construct(IcingaHost $host)
{
$this->host = $host;
$this->flatHost = $host->toPlainObject(true, false);
static::flattenVars($this->flatHost);
}
}
}