IcingaObject: allow to access custom vars
This commit is contained in:
parent
8184605c32
commit
57d443157f
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Objects;
|
namespace Icinga\Module\Director\Objects;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\CustomVariable\CustomVariables;
|
||||||
use Icinga\Module\Director\Data\Db\DbObject;
|
use Icinga\Module\Director\Data\Db\DbObject;
|
||||||
use Icinga\Module\Director\IcingaConfigHelper as c;
|
use Icinga\Module\Director\IcingaConfigHelper as c;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
@ -22,6 +23,28 @@ abstract class IcingaObject extends DbObject
|
||||||
return $this->supportsCustomVars;
|
return $this->supportsCustomVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function assertCustomVarsSupport()
|
||||||
|
{
|
||||||
|
if (! $this->supportsCustomVars()) {
|
||||||
|
throw new ProgrammingError(
|
||||||
|
'Objects of type "%s" have no custom vars',
|
||||||
|
$this->getType()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function vars()
|
||||||
|
{
|
||||||
|
$this->assertCustomVarsSupport();
|
||||||
|
if ($this->vars === null) {
|
||||||
|
$this->vars = new CustomVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->vars;
|
||||||
|
}
|
||||||
|
|
||||||
public function isTemplate()
|
public function isTemplate()
|
||||||
{
|
{
|
||||||
return $this->hasProperty('object_type')
|
return $this->hasProperty('object_type')
|
||||||
|
|
Loading…
Reference in New Issue