Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1aaaa1b

Browse files
committed
feature#15200 [Workflow] Added explaination on context in events and initial marking (epitre)
This PR was submitted for the 5.x branch but it was merged into the 5.2 branch instead.Discussion----------[Workflow] Added explaination on context in events and initial markingFinihes#14678Commits-------5a8ce04 Added explaination on context in events and initial marking
2 parents6bd8350 +5a8ce04 commit1aaaa1b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎workflow.rst

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp