@@ -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+
6064The ``Workflow `` can now help you to decide what actions are allowed
6165on a blog post depending on what *place * it is in. This will keep your domain
6266logic in one place and not spread all over your application.
0 commit comments