mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 01:04:12 +02:00
IcingaObject: add userspace filters
This commit is contained in:
parent
d8a5e9a636
commit
dabc6de1da
@ -7,6 +7,7 @@ use Icinga\Module\Director\Data\Db\DbObject;
|
|||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
|
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
|
/* key/value!! */
|
||||||
protected $booleans = array();
|
protected $booleans = array();
|
||||||
|
|
||||||
private $vars;
|
private $vars;
|
||||||
@ -370,6 +372,35 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
return $vals;
|
return $vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function matches(Filter $filter)
|
||||||
|
{
|
||||||
|
return $filter->matches($this->flattenProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function flattenProperties()
|
||||||
|
{
|
||||||
|
$db = $this->getDb();
|
||||||
|
$obj = (object) array();
|
||||||
|
foreach ($this->getProperties() as $k => $v) {
|
||||||
|
$obj->$k = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->supportsCustomVars()) {
|
||||||
|
/*
|
||||||
|
foreach ($this->getVars() as $k => $v) {
|
||||||
|
$obj->{'vars.' . $k} = $v;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cloneFullyResolved()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
protected function assertCustomVarsSupport()
|
protected function assertCustomVarsSupport()
|
||||||
{
|
{
|
||||||
if (! $this->supportsCustomVars()) {
|
if (! $this->supportsCustomVars()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user