From 2f3e5fb419aa7abff32397b5719b641a730b3375 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 20 Feb 2017 14:19:52 +0100 Subject: [PATCH] BpConfig: allow access to a fake unbound base node fixes #100 --- library/Businessprocess/BpConfig.php | 24 +++++++++++++++++++ library/Businessprocess/Renderer/Renderer.php | 20 +--------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/library/Businessprocess/BpConfig.php b/library/Businessprocess/BpConfig.php index 884e1ca..ba33934 100644 --- a/library/Businessprocess/BpConfig.php +++ b/library/Businessprocess/BpConfig.php @@ -483,6 +483,11 @@ class BpConfig */ public function getNode($name) { + if ($name === '__unbound__') { + return $this->getUnboundBaseNode(); + + } + if (array_key_exists($name, $this->nodes)) { return $this->nodes[$name]; } @@ -506,6 +511,25 @@ class BpConfig ); } + /** + * @return BpNode + */ + public function getUnboundBaseNode() + { + // Hint: state is useless here, but triggers parent/child "calculation" + // This is an ugly workaround and should be made obsolete + $this->calculateAllStates(); + + $names = array_keys($this->getUnboundNodes()); + $bp = new BpNode($this, (object) array( + 'name' => '__unbound__', + 'operator' => '&', + 'child_names' => $names + )); + $bp->setAlias($this->translate('Unbound nodes')); + return $bp; + } + /** * @param $name * @return BpNode diff --git a/library/Businessprocess/Renderer/Renderer.php b/library/Businessprocess/Renderer/Renderer.php index e17efa5..e5b98db 100644 --- a/library/Businessprocess/Renderer/Renderer.php +++ b/library/Businessprocess/Renderer/Renderer.php @@ -309,25 +309,7 @@ abstract class Renderer extends Html protected function createUnboundParent(BpConfig $bp) { - // Hint: state is useless here, but triggers parent/child "calculation" - // This is an ugly workaround and should be made obsolete - foreach ($bp->getBpNodes() as $p) { - $p->getState(); - } - $unbound = $bp->getUnboundNodes(); - - $parent = new BpNode($bp, (object) array( - 'name' => '__unbound__', - 'operator' => '|', - 'child_names' => array_keys($unbound) - )); - $parent->getState(); - $parent->setMissing() - ->setDowntime(false) - ->setAck(false) - ->setAlias('Unbound nodes'); - - return $parent; + return $bp->getNode('__unbound__'); } /**