Skip to content

Commit 5a568b5

Browse files
committed
rearrange how workflow events are presented
1 parent 1cd1950 commit 5a568b5

File tree

1 file changed

+48
-30
lines changed

1 file changed

+48
-30
lines changed

workflow/usage.rst

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ like this:
148148
The marking store type could be "multiple_state" or "single_state".
149149
A single state marking store does not support a model being on multiple places
150150
at the same time.
151-
151+
152152
.. tip::
153153

154154
The ``type`` (default value ``single_state``) and ``arguments`` (default value ``marking``)
@@ -189,35 +189,53 @@ Each step has three events that are fired in order:
189189
* An event for the workflow concerned;
190190
* An event for the workflow concerned with the specific transition or place name.
191191

192-
The following events are dispatched:
192+
When a state transition is initiated, the events are fired in the following order:
193193

194-
* ``workflow.guard``
195-
* ``workflow.[workflow name].guard``
196-
* ``workflow.[workflow name].guard.[transition name]``
194+
``workflow.guard``
195+
Validate whether the transition is allowed at all (:ref:`see below <workflow-usage-guard-events>`).
197196

198-
* ``workflow.leave``
199-
* ``workflow.[workflow name].leave``
200-
* ``workflow.[workflow name].leave.[place name]``
197+
The three events being fired are:
201198

202-
* ``workflow.transition``
203-
* ``workflow.[workflow name].transition``
204-
* ``workflow.[workflow name].transition.[transition name]``
199+
* ``workflow.guard``
200+
* ``workflow.[workflow name].guard``
201+
* ``workflow.[workflow name].guard.[transition name]``
205202

206-
* ``workflow.enter``
207-
* ``workflow.[workflow name].enter``
208-
* ``workflow.[workflow name].enter.[place name]``
203+
``workflow.leave``
204+
The object is about to leave a place.
209205

210-
* ``workflow.announce``
211-
* ``workflow.[workflow name].announce``
212-
* ``workflow.[workflow name].announce.[transition name]``
206+
The three events being fired are:
213207

214-
When a state transition is initiated, the events are fired in the following order:
208+
* ``workflow.leave``
209+
* ``workflow.[workflow name].leave``
210+
* ``workflow.[workflow name].leave.[place name]``
211+
212+
``workflow.transition``
213+
The object is going through this transition.
214+
215+
The three events being fired are:
216+
217+
* ``workflow.transition``
218+
* ``workflow.[workflow name].transition``
219+
* ``workflow.[workflow name].transition.[transition name]``
215220

216-
- guard: Validate whether the transition is allowed at all (:ref:`see below <workflow-usage-guard-events>`);
217-
- leave: The object is about to leave a place;
218-
- transition: The object is going through this transition;
219-
- enter: The object entered a new place. This is the first event where the object' is marked as being in the new place;
220-
- announce: Triggered once for each workflow that now is available for the object.
221+
``workflow.enter``
222+
The object entered a new place. This is the first event where the object
223+
is marked as being in the new place.
224+
225+
The three events being fired are:
226+
227+
* ``workflow.enter``
228+
* ``workflow.[workflow name].enter``
229+
* ``workflow.[workflow name].enter.[place name]``
230+
231+
``workflow.announce``
232+
Triggered once for each workflow that now is available for the object.
233+
234+
The three events being fired are:
235+
236+
* ``workflow.announce``
237+
* ``workflow.[workflow name].announce``
238+
* ``workflow.[workflow name].announce.[transition name]``
221239

222240
Here is an example how to enable logging for every time a the "blog_publishing" workflow leaves a place::
223241

@@ -231,7 +249,7 @@ Here is an example how to enable logging for every time a the "blog_publishing"
231249
{
232250
$this->logger = $logger;
233251
}
234-
252+
235253
public function onLeave(Event $event)
236254
{
237255
$this->logger->alert(sprintf(
@@ -242,7 +260,7 @@ Here is an example how to enable logging for every time a the "blog_publishing"
242260
implode(', ', $event->getTransition()->getTos())
243261
));
244262
}
245-
263+
246264
public static function getSubscribedEvents()
247265
{
248266
return array(
@@ -253,14 +271,14 @@ Here is an example how to enable logging for every time a the "blog_publishing"
253271

254272
.. _workflow-usage-guard-events:
255273

256-
Guard events
274+
Guard Events
257275
~~~~~~~~~~~~
258276

259-
There are a special kind of events called "Guard events". Their event listeners
260-
are invoked every time a call to ``Workflow::can``, ``Workflow::apply`` or
277+
There are a special kind of events called "Guard events". Their event listeners
278+
are invoked every time a call to ``Workflow::can``, ``Workflow::apply`` or
261279
``Workflow::getEnabledTransitions`` is executed. With the guard events you may
262-
add custom logic to decide what transitions that are valid or not. Here is a list
263-
of the guard event names.
280+
add custom logic to decide what transitions that are valid or not. Here is a list
281+
of the guard event names.
264282

265283
* ``workflow.guard``
266284
* ``workflow.[workflow name].guard``

0 commit comments

Comments
 (0)