diff --git a/library/Businessprocess/BpNode.php b/library/Businessprocess/BpNode.php index 2d34f4f..7eb5082 100644 --- a/library/Businessprocess/BpNode.php +++ b/library/Businessprocess/BpNode.php @@ -262,6 +262,10 @@ class BpNode extends Node public function toLegacyConfigString(& $rendered = array()) { $cfg = ''; + if (array_key_exists($this->name, $rendered)) { + return $cfg; + } + $rendered[$this->name] = true; $children = array(); foreach ($this->getChildren() as $name => $child) { @@ -270,7 +274,6 @@ class BpNode extends Node if ($child instanceof BpNode) { $cfg .= $child->toLegacyConfigString($rendered) . "\n"; } - $rendered[$name] = true; } $eq = '='; $op = $this->operator; @@ -278,11 +281,16 @@ class BpNode extends Node $eq = '= ' . $op . ' of:'; $op = '+'; } + + $strChildren = implode(' ' . $op . ' ', $children); + if ((count($children) < 2) && $op !== '&') { + $strChildren = $op . ' ' . $strChildren; + } $cfg .= sprintf( "%s %s %s\n", $this->name, $eq, - implode(' ' . $op . ' ', $children) + $strChildren ); if ($this->hasAlias() || $this->getDisplay() > 0) { $prio = $this->getDisplay(); diff --git a/library/Businessprocess/BusinessProcess.php b/library/Businessprocess/BusinessProcess.php index d3be2a5..53b6ca3 100644 --- a/library/Businessprocess/BusinessProcess.php +++ b/library/Businessprocess/BusinessProcess.php @@ -629,12 +629,12 @@ class BusinessProcess $rendered = array(); foreach ($this->getChildren() as $child) { - $rendered[(string) $child] = true; $conf .= $child->toLegacyConfigString($rendered); + $rendered[(string) $child] = true; } foreach ($this->getUnboundNodes() as $node) { - $rendered[(string) $node] = true; $conf .= $node->toLegacyConfigString($rendered); + $rendered[(string) $node] = true; } return $conf . "\n"; }