IcingaObject: move duplicate logic to common func

This commit is contained in:
Thomas Gelf 2016-10-09 13:15:05 +00:00
parent 3423ddf605
commit e96db8b296
1 changed files with 9 additions and 12 deletions

View File

@ -1279,15 +1279,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return;
}
$type = $this->getShortTableName();
if ($this->isTemplate()) {
$filename = strtolower($type) . '_templates';
} elseif ($this->isApplyRule()) {
$filename = strtolower($type) . '_apply';
} else {
$filename = strtolower($type) . 's';
}
$filename = $this->getRenderingFilename();
if ($config->isLegacy()) {
@ -1333,6 +1325,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return;
}
$config->configFile(
'zones.d/' . $this->getRenderingZone($config) . '/' . $this->getRenderingFilename()
)->addObject($this);
}
public function getRenderingFilename()
{
$type = $this->getShortTableName();
if ($this->isTemplate()) {
@ -1343,9 +1342,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
$filename = strtolower($type) . 's';
}
$config->configFile(
'zones.d/' . $this->getRenderingZone($config) . '/' . $filename
)->addObject($this);
return $filename;
}
public function getRenderingZone(IcingaConfig $config = null)