icingaweb2-module-businessp.../library/Businessprocess/Web/Form/Element/StateOverrides.php
Johannes Meyer 0c7fca926f config: Use an extra line to store state overrides
Storing overrides as part of a node's name leads to way too complicated
code. A separate field is not only better for compatibility but also
more straightforward to process.
2020-06-26 14:08:05 +02:00

52 lines
959 B
PHP

<?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 = [];
foreach ($value as $from => $to) {
if ((int) $from !== (int) $to) {
$cleanedValue[$from] = $to;
}
}
return parent::setValue($cleanedValue);
}
}