From 3196e1ed168b684b29635b2a1b47b5f801861f84 Mon Sep 17 00:00:00 2001 From: Stefan Gehrig Date: Wed, 17 Jan 2018 09:07:46 +0100 Subject: [PATCH 1/3] fixes issue #13 with passing variables from and to sub-workflows --- src/nodes/sub_workflow.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/nodes/sub_workflow.php b/src/nodes/sub_workflow.php index a50bf24..36033c9 100644 --- a/src/nodes/sub_workflow.php +++ b/src/nodes/sub_workflow.php @@ -9,9 +9,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -163,7 +163,14 @@ public function execute( ezcWorkflowExecution $execution ) { $subExecution = $execution->getSubExecution( $this->state ); $subExecution->workflow = $workflow; - $subExecution->resume( $execution->getVariables() ); + + $subVariables = []; + foreach ( $execution->getVariables() as $variableName => $data ) { + if ( isset($this->configuration['variables']['in'][$variableName]) ) { + $subVariables[$this->configuration['variables']['in'][$variableName]] = $data; + } + } + $subExecution->resume( $subVariables ); } } @@ -188,9 +195,10 @@ public function execute( ezcWorkflowExecution $execution ) } // Execution of Sub Workflow has been suspended. + $reverseInVariableMap = array_flip( $this->configuration['variables']['in'] ); foreach ( $subExecution->getWaitingFor() as $variableName => $data ) { - $execution->addWaitingFor( $this, $variableName, $data['condition'] ); + $execution->addWaitingFor( $this, $reverseInVariableMap[$variableName], $data['condition'] ); } return false; @@ -298,7 +306,9 @@ protected function passVariables( ezcWorkflowExecution $from, ezcWorkflowExecuti { foreach ( $variables as $fromName => $toName ) { - $to->setVariable( $toName, $from->getVariable( $fromName ) ); + if ( $from->hasVariable( $fromName ) ) { + $to->setVariable( $toName, $from->getVariable( $fromName ) ); + } } } } From 25c1f6909c9be64ba5ac31ef28f9c988f81125d5 Mon Sep 17 00:00:00 2001 From: Stefan Gehrig Date: Wed, 17 Jan 2018 11:32:01 +0100 Subject: [PATCH 2/3] fixes { placement according to coding style --- src/nodes/sub_workflow.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nodes/sub_workflow.php b/src/nodes/sub_workflow.php index 36033c9..cf0dd07 100644 --- a/src/nodes/sub_workflow.php +++ b/src/nodes/sub_workflow.php @@ -165,8 +165,10 @@ public function execute( ezcWorkflowExecution $execution ) $subExecution->workflow = $workflow; $subVariables = []; - foreach ( $execution->getVariables() as $variableName => $data ) { - if ( isset($this->configuration['variables']['in'][$variableName]) ) { + foreach ( $execution->getVariables() as $variableName => $data ) + { + if ( isset($this->configuration['variables']['in'][$variableName]) ) + { $subVariables[$this->configuration['variables']['in'][$variableName]] = $data; } } From 7595a2a9e721138d768c6bd9e2d521f1f2c7dcbc Mon Sep 17 00:00:00 2001 From: Stefan Gehrig Date: Wed, 17 Jan 2018 11:35:00 +0100 Subject: [PATCH 3/3] fixes whitespace --- src/nodes/sub_workflow.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nodes/sub_workflow.php b/src/nodes/sub_workflow.php index cf0dd07..5017f99 100644 --- a/src/nodes/sub_workflow.php +++ b/src/nodes/sub_workflow.php @@ -9,9 +9,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY