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 ee47e38

Browse filesBrowse files
committed
Used the new fluent interface for DefinitionBuilder example
1 parent 2b1dbee commit ee47e38
Copy full SHA for ee47e38

File tree

Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed

‎components/workflow.rst

Copy file name to clipboardExpand all lines: components/workflow.rst
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,23 @@ these statuses are called **places**. You can define the workflow like this::
4444
use Symfony\Component\Workflow\Workflow;
4545
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
4646

47-
$builder = new DefinitionBuilder();
48-
$builder->addPlaces(['draft', 'review', 'rejected', 'published']);
49-
50-
// Transitions are defined with a unique name, an origin place and a destination place
51-
$builder->addTransition(new Transition('to_review', 'draft', 'review'));
52-
$builder->addTransition(new Transition('publish', 'review', 'published'));
53-
$builder->addTransition(new Transition('reject', 'review', 'rejected'));
54-
55-
$definition = $builder->build();
47+
$definition = new DefinitionBuilder()
48+
->addPlaces(['draft', 'review', 'rejected', 'published'])
49+
// Transitions are defined with a unique name, an origin place and a destination place
50+
->addTransition(new Transition('to_review', 'draft', 'review'))
51+
->addTransition(new Transition('publish', 'review', 'published'))
52+
->addTransition(new Transition('reject', 'review', 'rejected'))
53+
->build()
54+
;
5655

5756
$marking = new SingleStateMarkingStore('currentState');
5857
$workflow = new Workflow($definition, $marking);
5958

59+
.. versionadded:: 3.3
60+
The fluent interface for the ``DefinitionBuilder`` class was introduced in
61+
Symfony 3.3. Before you had to call the ``addPlaces()``, ``addTransition()``
62+
and ``build()`` methods separately.
63+
6064
The ``Workflow`` can now help you to decide what actions are allowed
6165
on a blog post depending on what *place* it is in. This will keep your domain
6266
logic in one place and not spread all over your application.

0 commit comments

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