We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any sample code creating a ProcessContext, Events, and starting the workflow?
The text was updated successfully, but these errors were encountered:
If you directly use Workflower and PHPMentorsWorkflowerBundle, a code for starting processes of a workflow would be as the following:
// ... class LoanRequestProcessStartUsecase implements CommandUsecaseInterface, ProcessAwareInterface { // ... /** * @var EntityManagerInterface */ private $entityManager; /** * @var Process */ private $process; // ... /** * {@inheritdoc} */ public function setProcess(Process $process) { $this->process = $process; } /** * {@inheritdoc} * * @return void */ public function run(EntityInterface $entity) { assert($entity instanceof EventContextInterface); assert($entity->getProcessContext() instanceof LoanRequestProcess); $this->process->start($entity); // ... $loanRequestProcess = $entity->getProcessContext(); /* @var $loanRequestProcess LoanRequestProcess */ $loanRequestProcess->setCurrentTask($loanRequestProcess->getWorkflow()->getCurrentFlowObject()->getId()); // set some information for query $this->entityManager->beginTransaction(); try { $this->loanRequestProcessRepository->add($loanRequestProcess); $this->entityManager->flush(); $this->entityManager->commit(); } catch (\Exception $e) { $this->entityManager->rollback(); throw $e; } } }
In these cases, the usecase object would be called from controllers, CLI commands, and event listeners as the following:
// ... class LoanRequestProcessListener { // ... /** * @var LoanRequestProcessStartUsecase */ private $loanRequestProcessStartUsecase; // ... /** * @param LoanRequestApplicationEvent $event */ public function onSuccess(LoanRequestApplicationEvent $event) { try { $this->loanRequestProcessStartUsecase->run(new EventContext('Start', new LoanRequestProcess($event->getLoanRequestApplication())); } catch (\Exception $e) { // ... } // ... } }
Sorry, something went wrong.
iteman
No branches or pull requests
Is there any sample code creating a ProcessContext, Events, and starting the workflow?
The text was updated successfully, but these errors were encountered: