Step engine: Workflow overview
Edit on GitHubTo define a multi-step process using the StepEngine feature, you need to implement the following interfaces:
StepInterface
: Implements the logic that needs to get executed when the defined step takes placeSubFormInterface
: Defines the name of the form andpathProperty
, which is used to fill the property of a transfer object for the current step.DataContainerInterface
: Holds the transfer object you are working on.
Defining steps
The defined steps are wired up through the parameters that are passed when creating StepEngine
:
StepCollectionInterface
: Contains all the steps that are used in theStepEngine::process()
DataContainerInterface
: Holds the main transfer object and knows how to persist the data during the requests
StepEngine
takes care of executing the steps defined in your StepCollection
. To start the multi-step workflow, you need to call the StepEngine::process()
operation from your controller and pass the request object to it; optionally, you can pass FormCollectionHandlerInterface
to it.
Processing the workflow
When StepEngine
starts to process the multi-step workflow, it iterates through the steps contained in the step collection.
For the current step, it checks if it meets the assigned preconditions by calling StepInterface::preCondition()
.
- The preconditions are not satisfied:
StepEngine
returnsRedirectResponse
to the definedStepInterface::getEscapeRoute()
. - The preconditions are satisfied:
StepEngine
asksStepCollection
if the current step can be accessed.
If the preconditions are satisfied and the current step can be accessed, StepEngine
needs to verify if the current step needs user input:
- The current step doesn’t need user input:
StepEngine
returnsRedirectResponse
to the next step. - The current step needs user input:
StepEngine
takes the Request object and passes it toFormCollectionHandlerInterface
.
If you have a submitted form, FormCollectionHandlerInterface
handles the request, and if the form validation passes StepEngine
, the execution of the workflow continues.
If the request does not contain valid data for the given form, it redirects the user to the last URL, where the user can correct his input data and submit it again.
StepEngine
goes like this through all the steps added to StepCollection
until all the steps are executed.
The StepCollection
, FormCollectionHandler
, and StepEngine
classes can be used without the need to extend them in your project.
Thank you!
For submitting the form