From e0529ee8449688d0d164a7702183dd406e774a09 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 21 Feb 2019 08:09:58 +0100 Subject: [PATCH] Revert "Node: Aggregate parents if none are registered yet" This reverts commit d1f32c59f1c9bf041fa9092cce5a91dc816b9f1d. --- application/controllers/NodeController.php | 9 +++++++++ library/Businessprocess/Node.php | 17 ++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/application/controllers/NodeController.php b/application/controllers/NodeController.php index d557050..1d8fe0a 100644 --- a/application/controllers/NodeController.php +++ b/application/controllers/NodeController.php @@ -25,6 +25,15 @@ class NodeController extends Controller foreach ($this->storage()->listProcessNames() as $configName) { $config = $this->storage()->loadProcess($configName); + // TODO: Fix issues with children, they do not exist unless resolved :-/ + // This is a workaround: + foreach ($config->getRootNodes() as $node) { + $node->getState(); + } + foreach ($config->getRootNodes() as $node) { + $node->clearState(); + } + if (! $config->hasNode($name)) { continue; } diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index 662aca6..11cd69e 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -50,7 +50,7 @@ abstract class Node * * @var array */ - protected $parents; + protected $parents = array(); /** * Node identifier @@ -304,7 +304,7 @@ abstract class Node public function hasParents() { - return count($this->getParents()) > 0; + return count($this->parents) > 0; } public function hasParentName($name) @@ -321,7 +321,7 @@ abstract class Node public function removeParent($name) { $this->parents = array_filter( - $this->getParents(), + $this->parents, function (BpNode $parent) use ($name) { return $parent->getName() !== $name; } @@ -335,15 +335,6 @@ abstract class Node */ public function getParents() { - if ($this->parents === null) { - $this->parents = []; - foreach ($this->bp->getBpNodes() as $name => $node) { - if ($node->hasChild($this->getName())) { - $this->parents[] = $node; - } - } - } - return $this->parents; } @@ -357,7 +348,7 @@ abstract class Node } $paths = array(); - foreach ($this->getParents() as $parent) { + foreach ($this->parents as $parent) { foreach ($parent->getPaths() as $path) { $path[] = $this->getName(); $paths[] = $path;