The Simple Merge workflow pattern is to be used to merge the possible paths that are defined by a preceding Exclusive Choice. It is assumed that of these possible paths exactly one is taken and no synchronization takes place. Use Case Example: After the payment has been performed by either credit card or bank transfer, the order can be processed further. Incoming nodes: 2..* Outgoing nodes: 1 This example displays how you can use a simple merge to tie together two different execution paths from an exclusive choice into one. new ezcWorkflowConditionIsInt ) ); $workflow->startNode->addOutNode( $input ); create the exclusive choice branching node $choice = new ezcWorkflowNodeExclusiveChoice; $intput->addOutNode( $choice ); $branch1 = ....; // create nodes for the first branch of execution here.. $branch2 = ....; // create nodes for the second branch of execution here.. add the outnodes and set the conditions on the exclusive choice $choice->addConditionalOutNode( new ezcWorkflowConditionVariable( 'value', new ezcWorkflowConditionGreatherThan( 10 ) ), $branch1 ); $choice->addConditionalOutNode( new ezcWorkflowConditionVariable( 'value', new ezcWorkflowConditionLessThan( 11 ) ), $branch2 ); Merge the two branches together and continue execution. $merge = new ezcWorkflowNodeSimpleMerge(); $merge->addInNode( $branch1 ); $merge->addInNode( $branch2 ); $merge->addOutNode( $workflow->endNode ); ?>
Наследование: extends ezcWorkflowNodeMerge
Пример #1
0
 protected function setUpNestedExclusiveChoiceSimpleMerge($x = true, $y = true)
 {
     $this->workflow = new ezcWorkflow('NestedExclusiveChoiceSimpleMerge');
     $setX = new ezcWorkflowNodeVariableSet(array('x' => $x));
     $setY = new ezcWorkflowNodeVariableSet(array('y' => $y));
     $setZ1 = new ezcWorkflowNodeVariableSet(array('z' => true));
     $setZ2 = new ezcWorkflowNodeVariableSet(array('z' => false));
     $setZ3 = new ezcWorkflowNodeVariableSet(array('z' => false));
     $this->workflow->startNode->addOutNode($setX);
     $branch1 = new ezcWorkflowNodeExclusiveChoice();
     $branch1->addInNode($setX);
     $branch1->addConditionalOutNode(new ezcWorkflowConditionVariable('x', new ezcWorkflowConditionIsTrue()), $setY);
     $branch1->addConditionalOutNode(new ezcWorkflowConditionVariable('x', new ezcWorkflowConditionIsFalse()), $setZ3);
     $branch2 = new ezcWorkflowNodeExclusiveChoice();
     $branch2->addInNode($setY);
     $branch2->addConditionalOutNode(new ezcWorkflowConditionVariable('y', new ezcWorkflowConditionIsTrue()), $setZ1);
     $branch2->addConditionalOutNode(new ezcWorkflowConditionVariable('y', new ezcWorkflowConditionIsFalse()), $setZ2);
     $nestedMerge = new ezcWorkflowNodeSimpleMerge();
     $nestedMerge->addInNode($setZ1)->addInNode($setZ2);
     $merge = new ezcWorkflowNodeSimpleMerge();
     $merge->addInNode($nestedMerge)->addInNode($setZ3)->addOutNode($this->workflow->endNode);
 }
Пример #2
0
// Create an Input node that expects a boolean workflow variable of name "choice".
$input = new ezcWorkflowNodeInput(array('choice' => new ezcWorkflowConditionIsBool()));
// Add the previously created Input node
// as an outgoing node to the start node.
$workflow->startNode->addOutNode($input);
// Create a new Exclusive Choice node and add it as an
// outgoing node to the previously created Input node.
// This node will choose which output to run based on the
// choice workflow variable.
$branch = new ezcWorkflowNodeExclusiveChoice();
$branch->addInNode($input);
// Either $true or $false will be run depending on
// the above choice.
// Note that neither $true nor $false are valid action nodes.
// see the next example
$trueNode = new ezcWorkflowNodeAction('PrintTrue');
$falseNode = new ezcWorkflowNodeAction('PrintFalse');
// Branch
// Condition: Variable "choice" has boolean value "true".
// Action:    PrintTrue service object.
$branch->addConditionalOutNode(new ezcWorkflowConditionVariable('choice', new ezcWorkflowConditionIsTrue()), $trueNode);
// Branch
// Condition: Variable "choice" has boolean value "false".
// Action:    PrintFalse service object.
$branch->addConditionalOutNode(new ezcWorkflowConditionVariable('choice', new ezcWorkflowConditionIsFalse()), $falseNode);
// Create SimpleMerge node and add the two possible threads of
// execution as incoming nodes of the end node.
$merge = new ezcWorkflowNodeSimpleMerge();
$merge->addInNode($trueNode);
$merge->addInNode($falseNode);
$merge->addOutNode($workflow->endNode);
Пример #3
0
 public function testForIssue14451()
 {
     $this->workflow = new ezcWorkflow('Test');
     $this->assertEquals(1, count($this->workflow));
     $this->assertEquals(1, count($this->workflow->nodes));
     $this->workflow->startNode->addOutNode($this->workflow->endNode);
     $this->assertEquals(2, count($this->workflow));
     $this->assertEquals(2, count($this->workflow->nodes));
     $this->workflow->startNode->removeOutNode($this->workflow->endNode);
     $this->assertEquals(1, count($this->workflow));
     $this->assertEquals(1, count($this->workflow->nodes));
     $input = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsInteger()));
     $this->workflow->startNode->addOutNode($input);
     $this->assertEquals(2, count($this->workflow));
     $this->assertEquals(2, count($this->workflow->nodes));
     $choice = new ezcWorkflowNodeExclusiveChoice();
     $input->addOutNode($choice);
     $this->assertEquals(3, count($this->workflow));
     $this->assertEquals(3, count($this->workflow->nodes));
     $branch1 = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsAnything()));
     $branch2 = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsAnything()));
     $choice->addConditionalOutNode(new ezcWorkflowConditionIsAnything(), $branch1);
     $this->assertEquals(4, count($this->workflow));
     $this->assertEquals(4, count($this->workflow->nodes));
     $choice->addConditionalOutNode(new ezcWorkflowConditionIsAnything(), $branch2);
     $this->assertEquals(5, count($this->workflow));
     $this->assertEquals(5, count($this->workflow->nodes));
     $merge = new ezcWorkflowNodeSimpleMerge();
     $merge->addInNode($branch1);
     $merge->addInNode($branch2);
     $merge->addOutNode($this->workflow->endNode);
     $this->assertEquals(7, count($this->workflow));
     $this->assertEquals(7, count($this->workflow->nodes));
 }