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 82a94f7

Browse filesBrowse files
committed
Added explaination on context in events and initial marking
1 parent 57e3020 commit 82a94f7
Copy full SHA for 82a94f7

File tree

2 files changed

+25
-0
lines changed
Filter options

2 files changed

+25
-0
lines changed

‎components/workflow.rst

Copy file name to clipboardExpand all lines: components/workflow.rst
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ you can retrieve a workflow from it and use it as follows::
9494
$workflow->can($blogPost, 'publish'); // True
9595
$workflow->getEnabledTransitions($blogPost); // $blogPost can perform transition "publish" or "reject"
9696

97+
If you want to initiate your worflow, you can simply call ``getMarking``::
98+
99+
// ...
100+
$blogPost = new BlogPost();
101+
$workflow = $registry->get($blogPost);
102+
103+
// initiate workflow
104+
$workflow->getMarking($blogPost);
105+
106+
97107
Learn more
98108
----------
99109

‎workflow.rst

Copy file name to clipboardExpand all lines: workflow.rst
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,26 @@ order:
356356

357357
The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1.
358358

359+
.. versionadded:: 5.2
360+
361+
The context will be accessible in all the events::
362+
363+
// $context must be an array
364+
$context = ['context'];
365+
$workflow->apply($subject, $transitionName, $context);
366+
367+
// in an event listener
368+
$context = $event->getContext(); // returns ['context']
369+
359370
.. note::
360371

361372
The leaving and entering events are triggered even for transitions that stay
362373
in same place.
363374

375+
.. note::
376+
377+
If you initialize the marking by calling ``$workflow->getMarking($object);``, then the ``workflow.[workflow name].entered.[initial place name]`` will be called with a default context ``Workflow::DEFAULT_INITIAL_CONTEXT``
378+
364379
Here is an example of how to enable logging for every time a "blog_publishing"
365380
workflow leaves a place::
366381

0 commit comments

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