mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
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.
52 lines
959 B
PHP
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);
|
|
}
|
|
}
|