IcingaConfigFile: add object counter support

This commit is contained in:
Thomas Gelf 2015-12-15 17:14:36 +01:00
parent 942363c65d
commit 30ce3d8d4f

View File

@ -15,6 +15,10 @@ class IcingaConfigFile
protected $checksum;
protected $cntObject = 0;
protected $cntTemplate = 0;
public function prepend($content)
{
$this->content = $content . $this->content;
@ -34,6 +38,28 @@ class IcingaConfigFile
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()
{
return Util::binary2hex($this->getChecksum());
@ -61,6 +87,20 @@ class IcingaConfigFile
{
$this->content .= $object->toConfigString();
$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;
}