From cd989f9c3aff968e19a3aeabc4eb9085787a6673 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:43:12 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- .../CustomVariable/CustomVariableString.php | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 library/Director/CustomVariable/CustomVariableString.php (limited to 'library/Director/CustomVariable/CustomVariableString.php') diff --git a/library/Director/CustomVariable/CustomVariableString.php b/library/Director/CustomVariable/CustomVariableString.php new file mode 100644 index 0000000..2d50968 --- /dev/null +++ b/library/Director/CustomVariable/CustomVariableString.php @@ -0,0 +1,59 @@ +getValue() === $this->getValue(); + } + + 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(); + } + + $this->deleted = false; + + return $this; + } + + public function flatten(array &$flat, $prefix) + { + // TODO: we should get rid of type=string and always use JSON + $flat[$prefix] = json_encode($this->getValue()); + } + + public function toConfigString($renderExpressions = false) + { + if ($renderExpressions) { + return c::renderStringWithVariables($this->getValue(), ['config']); + } else { + return c::renderString($this->getValue()); + } + } + + public function toLegacyConfigString() + { + return c1::renderString($this->getValue()); + } +} -- cgit v1.2.3