Skip to content

Documented support for DefinitionBuilder #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions components/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ Consider the following example for a blog post. A post can have one of a number
of predefined statuses (`draft`, `review`, `rejected`, `published`). In a workflow,
these statuses are called **places**. You can define the workflow like this::

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\DefinitionBuilder;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\MarkingStore\ScalarMarkingStore;

$states = ['draft', 'review', 'rejected', 'published'];
$builder = new DefinitionBuilder();
$builder->addPlaces(['draft', 'review', 'rejected', 'published']);

// Transitions are defined with a unique name, an origin place and a destination place
$transitions[] = new Transition('to_review', 'draft', 'review');
$transitions[] = new Transition('publish', 'review', 'published');
$transitions[] = new Transition('reject', 'review', 'rejected');
$builder->addTransition(new Transition('to_review', 'draft', 'review'));
$builder->addTransition(new Transition('publish', 'review', 'published'));
$builder->addTransition(new Transition('reject', 'review', 'rejected'));

$definition = new Definition($states, $transitions);
$definition->setInitialPlace('draft');
$definition = $builder->build();

$marking = new ScalarMarkingStore('currentState');
$workflow = new Workflow($definition, $marking);
Expand Down
3 changes: 1 addition & 2 deletions workflow/state-machines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ Below is the configuration for the pull request state machine.
$transitions[] = new Transition('rejected', 'review', 'closed');
$transitions[] = new Transition('reopened', 'closed', 'review');

$definition = new Definition($states, $transitions);
$definition->setInitialPlace('start');
$definition = new Definition($states, $transitions, 'start');

$marking = new ScalarMarkingStore('marking');
$stateMachine = new StateMachine($definition, $marking);
Expand Down
3 changes: 1 addition & 2 deletions workflow/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ like this:
$transitions[] = new Transition('publish', 'review', 'published');
$transitions[] = new Transition('reject', 'review', 'rejected');

$definition = new Definition($states, $transitions);
$definition->setInitialPlace('draft');
$definition = new Definition($states, $transitions, 'draft');

$marking = new PropertyAccessorMarkingStore('marking');
$workflow = new Workflow($definition, $marking);
Expand Down