Skip to content

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

Merged
merged 1 commit into from
Jun 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions workflow/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]``
Copy link
Contributor Author

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.


* ``workflow.leave``
* ``workflow.[workflow name].leave``
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The 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.
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand Down