2015-06-11 08:15:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\CustomVariable;
|
|
|
|
|
2015-06-11 22:44:17 +02:00
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
2016-10-14 11:53:04 +02:00
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
|
2015-06-11 08:15:51 +02:00
|
|
|
|
|
|
|
class CustomVariableString extends CustomVariable
|
|
|
|
{
|
|
|
|
public function equals(CustomVariable $var)
|
|
|
|
{
|
2015-11-01 00:54:43 +01:00
|
|
|
if (! $var instanceof CustomVariableString) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-11 08:15:51 +02:00
|
|
|
return $var->getValue() === $this->getValue();
|
|
|
|
}
|
|
|
|
|
2015-06-11 21:33:47 +02:00
|
|
|
public function getValue()
|
|
|
|
{
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue($value)
|
|
|
|
{
|
|
|
|
if (! is_string($value)) {
|
|
|
|
$value = (string) $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($value !== $this->value) {
|
|
|
|
$this->value = $value;
|
|
|
|
$this->setModified();
|
|
|
|
}
|
|
|
|
|
2016-09-09 00:40:07 +02:00
|
|
|
$this->deleted = false;
|
|
|
|
|
2015-06-11 21:33:47 +02:00
|
|
|
return $this;
|
2016-02-26 11:58:37 +01:00
|
|
|
}
|
2015-06-11 21:33:47 +02:00
|
|
|
|
2016-09-01 23:25:38 +02:00
|
|
|
public function toConfigString($renderExpressions = false)
|
2015-06-11 08:15:51 +02:00
|
|
|
{
|
2016-10-22 07:48:09 +02:00
|
|
|
if ($renderExpressions) {
|
|
|
|
return c::renderStringWithVariables($this->getValue());
|
|
|
|
} else {
|
|
|
|
return c::renderString($this->getValue());
|
|
|
|
}
|
2015-06-11 08:15:51 +02:00
|
|
|
}
|
2016-10-14 11:53:04 +02:00
|
|
|
|
|
|
|
public function toLegacyConfigString()
|
|
|
|
{
|
|
|
|
return c1::renderString($this->getValue());
|
|
|
|
}
|
2015-06-11 08:15:51 +02:00
|
|
|
}
|