From 0a9ed6ff398022c61907c5661011a502196cb7fd Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 2 Jan 2017 10:15:35 +0100 Subject: [PATCH] HostApplyMatches: allow usage for single hosts refs #13849 --- library/Director/Objects/HostApplyMatches.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/library/Director/Objects/HostApplyMatches.php b/library/Director/Objects/HostApplyMatches.php index 07df56b0..932f343b 100644 --- a/library/Director/Objects/HostApplyMatches.php +++ b/library/Director/Objects/HostApplyMatches.php @@ -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); } -} \ No newline at end of file +}