Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5eedb8e

Browse filesBrowse files
epitrewouterj
authored andcommitted
Added explaination on context in events and initial marking
1 parent b18d253 commit 5eedb8e
Copy full SHA for 5eedb8e

File tree

1 file changed

+25
-0
lines changed
Filter options

1 file changed

+25
-0
lines changed

‎workflow.rst

Copy file name to clipboardExpand all lines: workflow.rst
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,36 @@ order:
381381
* ``workflow.[workflow name].announce``
382382
* ``workflow.[workflow name].announce.[transition name]``
383383

384+
You can avoid triggering those events by using the context::
385+
386+
$workflow->apply($subject, $transitionName, [Workflow::DISABLE_ANNOUNCE_EVENT => true]);
387+
388+
.. versionadded:: 5.1
389+
390+
The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1.
391+
392+
.. versionadded:: 5.2
393+
394+
In Symfony 5.2, the context is accessible in all events::
395+
396+
// $context must be an array
397+
$context = ['context_key' => 'context_value'];
398+
$workflow->apply($subject, $transitionName, $context);
399+
400+
// in an event listener
401+
$context = $event->getContext(); // returns ['context']
402+
384403
.. note::
385404

386405
The leaving and entering events are triggered even for transitions that stay
387406
in same place.
388407

408+
.. note::
409+
410+
If you initialize the marking by calling ``$workflow->getMarking($object);``,
411+
then the ``workflow.[workflow_name].entered.[initial_place_name]`` event will
412+
be called with the default context (``Workflow::DEFAULT_INITIAL_CONTEXT``).
413+
389414
Here is an example of how to enable logging for every time a "blog_publishing"
390415
workflow leaves a place::
391416

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.