Skip to content

Commit

Permalink
Merge pull request #48 from winzou/sf4
Browse files Browse the repository at this point in the history
Update configuration for sf4
  • Loading branch information
winzou authored Aug 6, 2018
2 parents 6f5c1b5 + 75859b9 commit c90d496
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,18 @@ Let's imagine now that, after an exhaustive review, someone decides the `Article

The state machine is the object actually manipulating your object. By using the state machine you can test if a transition can be applied, actually apply a transition, retrieve the current state, etc. *A state machine is specific to a couple object + graph.* It means that if you want to manipulate another object, or the same object with another graph, *you need another state machine*.

The factory helps you to get the state machine for these couples object + graph. You give an object and a graph name to it, and it will return you the state machine for this couple. The factory is a service named `sm.factory`.
The factory helps you to get the state machine for these couples object + graph. You give an object and a graph name to it, and it will return you the state machine for this couple. The factory is a service named `SM\Factory\Factory`.

#### Usage


``` php
public function myAwesomeAction($id)
public function myAwesomeAction($id, \SM\Factory\Factory $factory)
{
// Get your domain object
$article = $this->getRepository('MyAwesomeBundle:Article')->find($id);
// Get the factory
$factory = $this->get('sm.factory');
// Get the state machine for this object, and graph called "simple"
$articleSM = $factory->get($article, 'simple');
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ services:
autowire: true
autoconfigure: true
public: false
bind:
$configs: "%sm.configs%"

# aliases for interfaces
SM\Factory\FactoryInterface:
Expand All @@ -20,6 +18,8 @@ services:
public: true
SM\Extension\Twig\SMExtension:
SM\Factory\Factory:
arguments:
$configs: "%sm.configs%"

# services from the bundle itself
winzou\Bundle\StateMachineBundle\Callback\ContainerAwareCallbackFactory:
Expand Down

0 comments on commit c90d496

Please sign in to comment.