From 94a22c23c31ff84afd50eda25a04f6693df208c6 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 16 Mar 2015 13:17:03 +0100 Subject: [PATCH] BusinessProcess: handle root node detection --- library/Businessprocess/BusinessProcess.php | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/library/Businessprocess/BusinessProcess.php b/library/Businessprocess/BusinessProcess.php index 3d30ccd..3568396 100644 --- a/library/Businessprocess/BusinessProcess.php +++ b/library/Businessprocess/BusinessProcess.php @@ -300,6 +300,20 @@ class BusinessProcess return $this; } + public function removeRootNode($name) + { + if ($this->isRootNode($name)) { + unset($this->root_nodes[$name]); + } + + return $this; + } + + public function isRootNode($name) + { + return array_key_exists($name, $this->root_nodes); + } + public function retrieveStatesFromBackend() { try { @@ -483,6 +497,18 @@ class BusinessProcess } $this->nodes[$name] = $node; + + if ($node->getDisplay() > 0) { + if (! $this->isRootNode($name)) { + $this->addRootNode($name); + } + } else { + if ($this->isRootNode($name)) { + $this->removeRootNode($name); + } + } + + return $this; } @@ -499,7 +525,7 @@ class BusinessProcess continue; } - if ($node->getDisplay() === '0') { + if ($node->getDisplay() === 0) { $nodes[(string) $node] = $node; } }