Skip to content

Instantly share code, notes, and snippets.

@marcelsud
Last active August 29, 2015 14:14
Show Gist options
  • Save marcelsud/abea3135d48ede85681d to your computer and use it in GitHub Desktop.
Save marcelsud/abea3135d48ede85681d to your computer and use it in GitHub Desktop.
workflow api draft
{
"start": "paymentTypeConditionalNode",
"paymentTypeConditionalNode": {
"credit_card": "creditcardSubWorkflow",
"debit_card": "debitSubWorkflow"
},
"creditcardSubWorkflow": "endMergeNode",
"debitSubWorkflow": "endMergeNode",
"endMergeNode": "end"
}
<?php
$startNode = new StartNode();
$creditcardSubWorkflow = new CreditcardSubWorkflow();
$debitSubWorkflow = new DebitSubWorkflow();
$endMergeNode = new SimpleMergeNode();
$endNode = new EndNode();
$paymentTypeConditionalNode = new ConditionalNode("payment_type", [
PaymentTypes::CREDIT_CARD => $creditcardSubWorkflow,
PaymentTypes::DEBIT => $debitSubWorkflow
]);
//Flow
$startNode->then($paymentTypeConditionalNode);
$creditcardSubWorkflow->then($endMergeNode);
$debitSubWorkflow->then($endMergeNode);
$endMergeNode->then($endNode);
$workflow = new Workflow($startNode);
// Running Workflow
$workflow->set("payment_type", PaymentTypes::CREDIT_CARD);
$workflowExecutor = new WorkflowExecutor($workflow);
$workflowExecutor->resume();
start: paymentTypeConditionalNode
paymentTypeConditionalNode:
credit_card: creditcardSubWorkflow
debit_card: debitSubWorkflow
creditcardSubWorkflow: endMergeNode
debitSubWorkflow: endMergeNode
endMergeNode: end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment