Last active
August 29, 2015 14:14
-
-
Save marcelsud/abea3135d48ede85681d to your computer and use it in GitHub Desktop.
workflow api draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"start": "paymentTypeConditionalNode", | |
"paymentTypeConditionalNode": { | |
"credit_card": "creditcardSubWorkflow", | |
"debit_card": "debitSubWorkflow" | |
}, | |
"creditcardSubWorkflow": "endMergeNode", | |
"debitSubWorkflow": "endMergeNode", | |
"endMergeNode": "end" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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