mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-07 22:19:35 -05:00
BpNode: unique operator validation
This commit is contained in:
parent
19ab1a28cc
commit
7d31250816
1 changed files with 26 additions and 7 deletions
|
|
@ -29,7 +29,7 @@ class BpNode extends Node
|
|||
) {
|
||||
$this->bp = $bp;
|
||||
$this->name = $object->name;
|
||||
$this->operator = $object->operator;
|
||||
$this->setOperator($object->operator);
|
||||
$this->setChildNames($object->child_names);
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +72,31 @@ class BpNode extends Node
|
|||
return $this->operator;
|
||||
}
|
||||
|
||||
public function setOperator($operator)
|
||||
{
|
||||
$this->assertValidOperator($operator);
|
||||
$this->operator = $operator;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function assertValidOperator($operator)
|
||||
{
|
||||
switch ($operator) {
|
||||
case self::OP_AND:
|
||||
case self::OP_OR:
|
||||
return;
|
||||
default:
|
||||
if (is_numeric($operator)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ConfigurationError(
|
||||
'Got invalid operator: %s',
|
||||
$operator
|
||||
);
|
||||
}
|
||||
|
||||
public function setInfoUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
|
@ -142,12 +167,6 @@ class BpNode extends Node
|
|||
break;
|
||||
default:
|
||||
// MIN:
|
||||
if (! is_numeric($this->operator)) {
|
||||
throw new ConfigurationError(
|
||||
'Got invalid operator: %s',
|
||||
$this->operator
|
||||
);
|
||||
}
|
||||
sort($sort_states);
|
||||
|
||||
// default -> unknown
|
||||
|
|
|
|||
Loading…
Reference in a new issue