2015-10-28 22:27:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\CustomVariable;
|
|
|
|
|
|
|
|
use Icinga\Exception\ProgrammingError;
|
|
|
|
|
|
|
|
class CustomVariableBoolean extends CustomVariable
|
|
|
|
{
|
|
|
|
public function equals(CustomVariable $var)
|
|
|
|
{
|
|
|
|
return $var->getValue() === $this->getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbFormat()
|
|
|
|
{
|
|
|
|
return 'json';
|
|
|
|
}
|
|
|
|
|
2016-02-23 10:15:39 +01:00
|
|
|
public function getDbValue()
|
|
|
|
{
|
|
|
|
return json_encode($this->getValue());
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:27:01 +01:00
|
|
|
public function getValue()
|
|
|
|
{
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue($value)
|
|
|
|
{
|
|
|
|
if (! is_bool($value)) {
|
|
|
|
throw new ProgrammingError(
|
|
|
|
'Expected a boolean, got %s',
|
|
|
|
var_export($value, 1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->value = $value;
|
2016-09-09 00:40:07 +02:00
|
|
|
$this->deleted = false;
|
2015-10-28 22:27:01 +01:00
|
|
|
|
|
|
|
return $this;
|
2016-02-26 11:58:37 +01:00
|
|
|
}
|
2015-10-28 22:27:01 +01:00
|
|
|
|
|
|
|
public function toConfigString()
|
|
|
|
{
|
|
|
|
return $this->value ? 'true' : 'false';
|
|
|
|
}
|
2016-10-14 11:53:04 +02:00
|
|
|
|
|
|
|
public function toLegacyConfigString()
|
|
|
|
{
|
|
|
|
return $this->toConfigString();
|
|
|
|
}
|
2015-10-28 22:27:01 +01:00
|
|
|
}
|