@@ -44,19 +44,23 @@ these statuses are called **places**. You can define the workflow like this::
44
44
use Symfony\Component\Workflow\Workflow;
45
45
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
46
46
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
+ ;
56
55
57
56
$marking = new SingleStateMarkingStore('currentState');
58
57
$workflow = new Workflow($definition, $marking);
59
58
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
+
60
64
The ``Workflow `` can now help you to decide what actions are allowed
61
65
on a blog post depending on what *place * it is in. This will keep your domain
62
66
logic in one place and not spread all over your application.
0 commit comments