An Event-aware State machine.
Uses the Symfony EventDispatcher Component
Inherits from: StateMachine
| StatefulInterface | $object | The stateful object |
| array | $states | The available states |
| array | $transitions | The available transitions |
| StateInterface | $currentState | The current state |
| __construct( StatefulInterface $object = null) | from StateMachine | |
|
initialize()
Initialize the State Machine current state |
||
| mixed |
apply( string $transitionName)
Apply a transition |
|
| bool |
can( string| TransitionInterface $transition)
Returns if the transition is applicable |
from StateMachine |
| addState( string| StateInterface $state) | from StateMachine | |
| addTransition( string| TransitionInterface $transition, string| null $initialState = null, string| null $finalState = null) | from StateMachine | |
| TransitionInterface |
getTransition( string $name)
Returns a transition by its name |
from StateMachine |
| StateInterface | getState( string $name) | from StateMachine |
| array<string> |
getTransitions()
Returns an array containing all the transitions names |
from StateMachine |
| array<string> |
getStates()
Returns an array containing all the states names |
from StateMachine |
| setObject( StatefulInterface $object) | from StateMachine | |
| StatefulInterface | getObject() | from StateMachine |
| StateInterface | getCurrentState() | from StateMachine |
| setEventDispatcher( EventDispatcherInterface $dispatcher) |
public
__construct( StatefulInterface $object = null)
public
initialize()
Initialize the State Machine current state
public mixed
apply( string $transitionName)
Apply a transition
| Parameters |
|
|||
|---|---|---|---|---|
| Return Value |
|
|||
public bool
can( string| TransitionInterface $transition)
Returns if the transition is applicable
| Parameters |
|
|||
|---|---|---|---|---|
| Return Value |
|
|||
public
addState( string| StateInterface $state)
public
addTransition( string| TransitionInterface $transition, string| null $initialState = null, string| null $finalState = null)
| Parameters |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Exceptions |
|
|||||||||
public TransitionInterface
getTransition( string $name)
Returns a transition by its name
| Parameters |
|
|||
|---|---|---|---|---|
| Return Value |
|
|||
| Exceptions |
|
|||
public StateInterface
getState( string $name)
public array<string>
getTransitions()
Returns an array containing all the transitions names
| Return Value |
|
|---|
public array<string>
getStates()
Returns an array containing all the states names
| Return Value |
|
|---|
public
setObject( StatefulInterface $object)
public StatefulInterface
getObject()
public StateInterface
getCurrentState()
public
setEventDispatcher( EventDispatcherInterface $dispatcher)
| Parameters |
|
|||
|---|---|---|---|---|