It is possible to add transition that have 'regex' states: states that
have a name in the format of 'regex://' or 'not-regex://'.
When adding a transition with a regex state, it will be matched against all currently
known states if there is a match. If you just want to use regex transitions,
it might be preferable to store some states via 'addState' first, so the
Self transitions for regex states are disallowed by default
since you would probably only want to do that explicitly. Regex states
can be both the 'to' and the 'from' state of a transition.
Transitions from a 'final' type of state are not allowed.
the order in which transitions are added matters insofar that when a
StateMachine::run() is called, the first Transition for the current State
will be tried first.
Since a transition has complete knowledge about it's states,
the addition of a transition will also trigger the adding of the
to and from state on this class.
this method can also be used to add a Transition directly (instead of via
a loader). Make sure that transitions that share a common State use the same
instance of that State object and vice versa.
public addTransition ( |
||
$transition | ||
$allow_self_transition_by_regex | boolean | optional: to allow regexes to set a self transition. |
return | integer | a count of how many transitions were added. In case of a regex transition this might be multiple and in case a transition already exists it might be 0. |