mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 01:04:12 +02:00
IcingaConfigFile: add object counter support
This commit is contained in:
parent
942363c65d
commit
30ce3d8d4f
@ -15,6 +15,10 @@ class IcingaConfigFile
|
|||||||
|
|
||||||
protected $checksum;
|
protected $checksum;
|
||||||
|
|
||||||
|
protected $cntObject = 0;
|
||||||
|
|
||||||
|
protected $cntTemplate = 0;
|
||||||
|
|
||||||
public function prepend($content)
|
public function prepend($content)
|
||||||
{
|
{
|
||||||
$this->content = $content . $this->content;
|
$this->content = $content . $this->content;
|
||||||
@ -34,6 +38,28 @@ class IcingaConfigFile
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getObjectCount()
|
||||||
|
{
|
||||||
|
return $this->cntObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateCount()
|
||||||
|
{
|
||||||
|
return $this->cntTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setObjectCount($cnt)
|
||||||
|
{
|
||||||
|
$this->cntObject = $cnt;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTemplateCount($cnt)
|
||||||
|
{
|
||||||
|
$this->cntTemplate = $cnt;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHexChecksum()
|
public function getHexChecksum()
|
||||||
{
|
{
|
||||||
return Util::binary2hex($this->getChecksum());
|
return Util::binary2hex($this->getChecksum());
|
||||||
@ -61,6 +87,20 @@ class IcingaConfigFile
|
|||||||
{
|
{
|
||||||
$this->content .= $object->toConfigString();
|
$this->content .= $object->toConfigString();
|
||||||
$this->checksum = null;
|
$this->checksum = null;
|
||||||
|
|
||||||
|
if ($object->hasProperty('object_type')) {
|
||||||
|
$type = $object->object_type;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'object':
|
||||||
|
$this->cntObject++;
|
||||||
|
break;
|
||||||
|
case 'template':
|
||||||
|
$this->cntTemplate++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user