IcingaObject: render disabled objects as comments

fixes #11922
This commit is contained in:
Thomas Gelf 2016-06-11 00:21:24 +02:00
parent cc9f5037f4
commit 0b92ca922f
2 changed files with 10 additions and 3 deletions

View File

@ -7,7 +7,7 @@
</div> </div>
<div class="content"> <div class="content">
<?php if ($object->disabled === 'y'): ?> <?php if ($this->isDisabled): ?>
<p class="error"><?= $this->translate('This object will not be deployed as it has been disabled') ?></p> <p class="error"><?= $this->translate('This object will not be deployed as it has been disabled') ?></p>
<?php endif ?> <?php endif ?>
<?php if ($this->isExternal): ?> <?php if ($this->isExternal): ?>

View File

@ -1123,7 +1123,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public function renderToConfig(IcingaConfig $config) public function renderToConfig(IcingaConfig $config)
{ {
if ($this->isDisabled() || $this->isExternal()) { if ($this->isExternal()) {
return; return;
} }
@ -1373,7 +1373,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public function toConfigString() public function toConfigString()
{ {
return implode(array( $str = implode(array(
$this->renderObjectHeader(), $this->renderObjectHeader(),
$this->renderImports(), $this->renderImports(),
$this->renderProperties(), $this->renderProperties(),
@ -1387,6 +1387,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
$this->renderAssignments(), $this->renderAssignments(),
$this->renderSuffix() $this->renderSuffix()
)); ));
if ($this->isDisabled()) {
return "// --- This object has been disabled ---\n// \n// "
. str_replace("\n", "\n// ", $str);
} else {
return $str;
}
} }
public function isGroup() public function isGroup()