File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -215,29 +215,29 @@ what actions are allowed on a blog post::
215
215
216
216
// See all the available transitions for the post in the current state
217
217
$transitions = $workflow->getEnabledTransitions($post);
218
-
218
+
219
219
Accessing the Workflow in a Class
220
220
---------------------------------
221
221
222
222
To access workflow inside a class, use dependency injection and inject the
223
223
registry in the constructor::
224
224
225
225
use Symfony\Component\Workflow\Registry;
226
-
226
+
227
227
class MyClass
228
228
{
229
-
229
+
230
230
private $workflowRegistry;
231
-
231
+
232
232
public function __construct(Registry $workflowRegistry)
233
233
{
234
234
$this->workflowRegistry = $workflowRegistry;
235
235
}
236
-
236
+
237
237
public function toReview(BlogPost $blogPost)
238
238
{
239
239
$workflow = $this->workflowRegistry->get($blogPost);
240
-
240
+
241
241
// Update the currentState on the post
242
242
try {
243
243
$workflow->apply($post, 'to_review');
@@ -339,6 +339,11 @@ order:
339
339
The leaving and entering events are triggered even for transitions that stay
340
340
in same place.
341
341
342
+ .. versionadded :: 4.3
343
+
344
+ Following events are also dispatched when the subject enters the workflow
345
+ for the first time: ``workflow.entered `` and ``workflow.[worflow name].entered ``.
346
+
342
347
Here is an example of how to enable logging for every time a "blog_publishing"
343
348
workflow leaves a place::
344
349
You can’t perform that action at this time.
0 commit c 31C5 omments