(Bp)Node: add get/hasMissingChildren method

This commit is contained in:
Thomas Gelf 2015-11-23 13:05:41 +01:00
parent 1e145f127f
commit 93fff13209
2 changed files with 35 additions and 1 deletions

View file

@ -19,6 +19,7 @@ class BpNode extends Node
protected $alias;
protected $counters;
protected $missing = null;
protected $missingChildren;
protected static $emptyStateSummary = array(
'OK' => 0,
@ -135,6 +136,25 @@ class BpNode extends Node
return $this->missing;
}
public function getMissingChildren()
{
if ($this->missingChildren === null) {
foreach ($this->getChildren() as $child) {
if ($child->isMissing()) {
$missing[(string) $child] = $child;
}
foreach ($child->getMissingChildren() as $m) {
$missing[(string) $m] = $m;
}
}
$this->missingChildren = $missing;
}
return $this->missingChildren;
}
public function getOperator()
{
return $this->operator;

View file

@ -127,6 +127,16 @@ abstract class Node
return $this->missing;
}
public function hasMissingChildren()
{
return count($this->getMissingChildren() > 0);
}
public function getMissingChildren()
{
return array();
}
public function hasInfoUrl()
{
return false;
@ -334,7 +344,11 @@ abstract class Node
if ($this->isMissing()) {
return array('missing');
} elseif ($state === 'ok') {
if ($this->hasMissingChildren()) {
return array('ok', 'missing-children');
} else {
return array('ok');
}
} else {
return array('problem', $state);
}