IcingaObject: render related sets
This commit is contained in:
parent
245e632f54
commit
47f20c93a3
|
@ -43,6 +43,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||||
// property => PropertyClass
|
// property => PropertyClass
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $relatedSets = array(
|
||||||
|
// property => ExtensibleSetClass
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of interval property names
|
* Array of interval property names
|
||||||
*
|
*
|
||||||
|
@ -79,6 +83,23 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||||
return array_key_exists($property, $this->intervalProperties);
|
return array_key_exists($property, $this->intervalProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function propertyIsRelatedSet($property)
|
||||||
|
{
|
||||||
|
return array_key_exists($property, $this->relatedSets);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRelatedSetClass($property)
|
||||||
|
{
|
||||||
|
$prefix = '\\Icinga\\Module\\Director\\IcingaConfig\\';
|
||||||
|
return $prefix . $this->relatedSets[$property];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRelatedSet($property)
|
||||||
|
{
|
||||||
|
$class = $this->getRelatedSetClass($property);
|
||||||
|
return $class::forIcingaObject($this, $property);
|
||||||
|
}
|
||||||
|
|
||||||
public function hasRelation($property)
|
public function hasRelation($property)
|
||||||
{
|
{
|
||||||
return array_key_exists($property, $this->relations);
|
return array_key_exists($property, $this->relations);
|
||||||
|
@ -935,6 +956,15 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderRelatedSets()
|
||||||
|
{
|
||||||
|
$config = '';
|
||||||
|
foreach ($this->relatedSets as $property => $class) {
|
||||||
|
$config .= $this->getRelatedSet($property)->renderAs($property);
|
||||||
|
}
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
protected function renderRelationProperty($propertyName, $id, $renderKey = null)
|
protected function renderRelationProperty($propertyName, $id, $renderKey = null)
|
||||||
{
|
{
|
||||||
return c::renderKeyValue(
|
return c::renderKeyValue(
|
||||||
|
@ -1010,6 +1040,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||||
$this->renderProperties(),
|
$this->renderProperties(),
|
||||||
$this->renderRanges(),
|
$this->renderRanges(),
|
||||||
$this->renderArguments(),
|
$this->renderArguments(),
|
||||||
|
$this->renderRelatedSets(),
|
||||||
$this->renderGroups(),
|
$this->renderGroups(),
|
||||||
$this->renderCustomExtensions(),
|
$this->renderCustomExtensions(),
|
||||||
$this->renderCustomVars(),
|
$this->renderCustomVars(),
|
||||||
|
|
Loading…
Reference in New Issue