Skip to content

Commit

Permalink
BpNode: add a new helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Gelf committed Jan 27, 2017
1 parent 6bb1c07 commit 61fd8ca
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion library/Businessprocess/BpNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Icinga\Module\Businessprocess;

use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Businessprocess\Exception\NestingError;

class BpNode extends Node
Expand Down Expand Up @@ -121,7 +122,7 @@ public function getProblematicChildren()
{
$problems = array();

foreach ($this->children as $child) {
foreach ($this->getChildren() as $child) {
if ($child->isProblem()
|| ($child instanceof BpNode && $child->hasProblems())
) {
Expand Down Expand Up @@ -444,6 +445,22 @@ public function getChildBpNodes()
return $children;
}

/**
* @param $childName
* @return Node
* @throws NotFoundError
*/
public function getChildByName($childName)
{
foreach ($this->getChildren() as $name => $child) {
if ($name === $childName) {
return $child;
}
}

throw new NotFoundError('Trying to get missing child %s', $childName);
}

protected function assertNumericOperator()
{
if (! is_numeric($this->operator)) {
Expand Down

0 comments on commit 61fd8ca

Please sign in to comment.