PHP Class izzum\statemachine\loader\LoaderArray

The LoaderArray should always be the object that is used by other Loader implementations. This means other LoaderInterface implementations should delegate the loading to this class. You could implement the Loader interface and use object composition for the LoaderArray. A transition will be unique per StateMachine and is uniquely defined by the tuple of a starting state name and a destination state name. The data of the rule, command or the identity (===) of the states does not matter when a Transition is added to a StateMachine. The machine will react on a first come first serve basis. In short, just make sure your configuration data is ok. TRICKY: if multiple transitions share the same State object (for example as their origin/from state or their destination/to state) then at least make sure that those states share the exact same data. Ideally, they should point to the same State instance. Otherwise, transitions and states are actually stored on the statemachine on a first wins basis (the later transition/state instance is not stored). Transitions will be sorted before they are added to the machine based on if they contain a regex or not. All regex transitions will be added to the machine after the non-regex transitions have been added.
See also: Transitions
See also: State
See also: PDO
Author: Rolf Vreijdenberger
Inheritance: implements izzum\statemachine\loader\Loader
Show file Open project: rolfvreijdenberger/izzum-statemachine Class Usage Examples

Protected Properties

Property Type Description
$transitions izzum\statemachine\Transition[]

Public Methods

Method Description
__construct ( Transition[] $transitions = [] )
__toString ( )
add ( Transition $transition ) add/overwrite a transition
count ( ) : integer counts the number of contained transitions.
getTransitions ( ) : Transition[] This method will return the transitions instances with the correct references to each other.
load ( StateMachine $stateMachine ) {@inheritDoc}
toString ( )

Method Details

__construct() public method

public __construct ( Transition[] $transitions = [] )
$transitions izzum\statemachine\Transition[] the transitions to be loaded

__toString() public method

public __toString ( )

add() public method

add/overwrite a transition
public add ( Transition $transition )
$transition izzum\statemachine\Transition

count() public method

this is not the same as the possible amount of transitions added (because of regex transitions)
public count ( ) : integer
return integer

getTransitions() public method

This method will return the transitions instances with the correct references to each other.
public getTransitions ( ) : Transition[]
return izzum\statemachine\Transition[]

load() public method

{@inheritDoc}
public load ( StateMachine $stateMachine )
$stateMachine izzum\statemachine\StateMachine

toString() public method

public toString ( )

Property Details

$transitions protected property

protected Transition[],izzum\statemachine $transitions
return izzum\statemachine\Transition[]