diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:42:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:42:35 +0000 |
commit | 18db984057b83ca4962c89b6b79bdce6a660b58f (patch) | |
tree | 2c9f23c086b4dfcb3e7eb2ec69210206b0782d3c /library/Businessprocess/Web/Form/Element/StateOverrides.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-businessprocess-18db984057b83ca4962c89b6b79bdce6a660b58f.tar.xz icingaweb2-module-businessprocess-18db984057b83ca4962c89b6b79bdce6a660b58f.zip |
Adding upstream version 2.4.0.upstream/2.4.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Businessprocess/Web/Form/Element/StateOverrides.php')
-rw-r--r-- | library/Businessprocess/Web/Form/Element/StateOverrides.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/library/Businessprocess/Web/Form/Element/StateOverrides.php b/library/Businessprocess/Web/Form/Element/StateOverrides.php new file mode 100644 index 0000000..c2216c0 --- /dev/null +++ b/library/Businessprocess/Web/Form/Element/StateOverrides.php @@ -0,0 +1,55 @@ +<?php + +namespace Icinga\Module\Businessprocess\Web\Form\Element; + +class StateOverrides extends FormElement +{ + public $helper = 'formStateOverrides'; + + /** @var array The overridable states */ + protected $states; + + /** + * Set the overridable states + * + * @param array $states + * + * @return $this + */ + public function setStates(array $states) + { + $this->states = $states; + + return $this; + } + + /** + * Get the overridable states + * + * @return array + */ + public function getStates() + { + return $this->states; + } + + public function init() + { + $this->setIsArray(true); + } + + public function setValue($value) + { + $cleanedValue = []; + + if (! empty($value)) { + foreach ($value as $from => $to) { + if ((int) $from !== (int) $to) { + $cleanedValue[$from] = $to; + } + } + } + + return parent::setValue($cleanedValue); + } +} |