-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
clarify workflow events #8048
New issue
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
clarify workflow events #8048
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,10 +177,23 @@ what actions are allowed on a blog post:: | |
Using Events | ||
------------ | ||
|
||
To make your workflows even more powerful you could construct the ``Workflow`` | ||
To make your workflows more flexible, you can construct the ``Workflow`` | ||
object with an ``EventDispatcher``. You can now create event listeners to | ||
block transitions (i.e. depending on the data in the blog post). The following | ||
events are dispatched: | ||
block transitions (i.e. depending on the data in the blog post) and do | ||
additional actions when a workflow operation happened (i.e. sending | ||
announcements). | ||
|
||
Each step has three events that are fired in order: | ||
|
||
- An event for every workflow; | ||
- An event for the workflow concerned; | ||
- An event for the workflow concerned with the specific transition or place name; | ||
|
||
The following events are dispatched: | ||
|
||
* ``workflow.guard`` | ||
* ``workflow.[workflow name].guard`` | ||
* ``workflow.[workflow name].guard.[transition name]`` | ||
|
||
* ``workflow.leave`` | ||
* ``workflow.[workflow name].leave`` | ||
|
@@ -198,6 +211,14 @@ events are dispatched: | |
* ``workflow.[workflow name].announce`` | ||
* ``workflow.[workflow name].announce.[transition name]`` | ||
|
||
When a state transition is initiated, the events are fired in the following order: | ||
|
||
- guard: Validate whether the transition is allowed at all (see below); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's link the see below part |
||
- leave: The object is about to leave a place; | ||
- transition: The object is going through this transition; | ||
- enter: The object entered a new place. This is the first event where the object' is marked as being in the new place; | ||
- announce: Triggered once for each workflow that now is available for the object. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we could integrate this with the event list above so it's all in one place. Perhaps the name (guard), then indented below the description, then bullets below that with the 3 events. We do something here https://github.com/symfony/symfony-docs/blob/master/introduction/http_fundamentals.rst for GET POST stuff There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks. see #8060 for this. it looks nice, at least in the github preview There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I already opened #8059 in the meantime. 🙈 |
||
|
||
Here is an example how to enable logging for every time a the "blog_publishing" workflow leaves a place:: | ||
|
||
use Psr\Log\LoggerInterface; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i found it illogic that these events are shown below, when they are also events, just a special type of events.