-
Notifications
You must be signed in to change notification settings - Fork 29
Check whether it is possible to reach a step (canReachNextStep) #17
Comments
Hi, `<process_name>.<current_step_name>.<next_step>.pre_validation` and
`<process_name>.<current_step_name>.<next_step>.pre_validation_fail` Before to reach the next step you can listen events and add violations and stay on the current step. Example : Imagine you have a process_name: "post_publication", a current step "draft_created" and a next_state "validate". So, you would like to check if you can reach the next step "validate". You need to listen on : And here you can add a violation for fail the validation. <?php
// your EventSubscriberInterface
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
'post_publication.draft_created.validate.pre_validation' => 'onValidateDraft',
'post_publication.draft_created.validate.pre_validation_fail' => 'onValidateDraftFail',
]
}
public function onValidateDraft(ValidateStepEvent $event)
{
/** @var Post $post */
$post = $event->getModel();
if ($userNotAllowed()) {
// The step will stay in its current status
$event->addViolation(
$this->translator->trans('blog.user.flash_error', [], 'BlogBundle')
);
}
//...
}
public function onValidateDraftFail(StepEvent $event)
{
$modelState = $event->getModelState();
// Do something with the modelState: logs, emails etc...
}
} May be you might be interested in this section also provide a history of the workflow : |
Hi, I'm using this project now to implement a workflow in my app. I have exactly the same issue, I want to render a botton to advance de workflow, obviously I only want to show this option to users that actually can advance the process. |
Hello, I'm interested in use LexikWorkflowBundle in my Company Project, but I dont know if i can use it together Symfony 3.2. I know WorkflowBundle too, but after test the example of 2016 at Paris, and take a look at of documentation in symfony web site, this, is not enough to begin a production proyect Could you help me? Thanks |
Hi,
when trying to use LexikWorkflowBundle for our project the need arose to be able to check whether a process can reach a next step without actually advancing the model to the next step. In more practical terms, I would like to know whether a user of my system is able to submit a certain web form before actually showing the form to the user. So I probably need something along the lines of:
Like this we avoid duplicating code in the workflow validators and form controllers.
Is there a function like this? I didn't find one.
If there is not, I would probably simply copy
$processHandler::reachNextState()
and adapt the method to my needs. This rises the next question:What is the best way to extend the ProcessHandler?
Cheers,
Andreas
The text was updated successfully, but these errors were encountered: