Метод | Описание | |
---|---|---|
__call ( string $name, array $arguments ) : boolean | This method is used to trigger an event on the statemachine and delegates the actuall call to the 'handle' method | |
__construct ( |
Constructor | |
__toString ( ) | ||
add ( string $message = null ) : boolean | add state information to the persistence layer if it is not there. | |
addState ( |
Add a state. without a transition. | |
addTransition ( |
Add a fully configured transition to the machine. | |
canHandle ( string $event ) : boolean | checks if one or more transitions are possible and/or allowed for the current state when triggered by an event | |
canTransition ( string $transition_name ) : boolean | Check if an existing transition on the curent state is allowed by the guard logic. | |
getContext ( ) : |
Get the current context | |
getCurrentState ( ) : |
gets the current state (or retrieve it from the backend if not set). | |
getInitialState ( boolean $allow_null = false ) : |
Get the initial state, the only state with type State::TYPE_INITIAL | |
getState ( string $name ) : |
get a state by name. | |
getStates ( ) : |
All known/loaded states for this statemachine | |
getTransition ( string $name ) : |
get a transition by name. | |
getTransitions ( ) : |
All known/loaded transitions for this statemachine | |
handle ( string $event, string $message = null ) : boolean | Try to apply a transition from the current state by handling an event string as a trigger. | |
hasEvent ( string $event ) : boolean | check if the current state has one or more transitions that can be triggered by an event | |
run ( string $message = null ) : boolean | Have the statemachine do the first possible transition. | |
runToCompletion ( string $message = null ) : integer | run a statemachine until it cannot run any transition in the current state or until it is in a final state. | |
setContext ( |
set the context on the statemachine and provide bidirectional association. | |
setState ( |
sets the state as the current state and on the backend. | |
toString ( $elaborate = false ) | ||
transition ( string $transition_name, string $message = null ) : boolean | Apply a transition by name. |
Метод | Описание | |
---|---|---|
_onCheckCanTransition ( |
hook method. | |
_onEnterState ( |
hook method. | |
_onExitState ( |
hook method. | |
_onTransition ( |
hook method. | |
addTransitionWithoutRegex ( |
Add the transition, after it has previously been checked that is did not contain states with a regex. | |
callEventHandler ( mixed $object, string $method ) : boolean | mixed | Helper method to generically call methods on the $object. | |
handlePossibleNonStatemachineException ( Exception $e, integer $code, |
Always throws an izzum exception (converts a non-izzum exception to an izzum exception) | |
handleTransitionException ( |
called whenever an exception occurs from inside 'performTransition()' can be used for logging etc. in some sort of history structure in the persistence layer |
Метод | Описание | |
---|---|---|
doCheckCanTransition ( |
Template method to call a hook and to call a possible method defined on the domain object/contextual entity | |
doEnterState ( |
the enter state action method | |
doExitState ( |
the exit state action method | |
doTransition ( |
the transition action method | |
getTransitionWithNullCheck ( string $name ) : |
Helper method that gets the Transition object from a transition name or throws an exception. | |
performTransition ( |
Perform a transition by specifiying the transitions' name from a state that the transition is allowed to run. |
public __call ( string $name, array $arguments ) : boolean | ||
$name | string | the name of the unknown method called |
$arguments | array | an array of arguments (if any). an argument could be $message (informational message for the transition) |
Результат | boolean | true in case a transition was triggered by the event, false otherwise |
public __construct ( |
||
$context | a fully configured context providing all the relevant parameters/dependencies to be able to run this statemachine for an entity. |
protected _onCheckCanTransition ( |
||
$transition | ||
Результат | boolean | if false, the transition and it's associated logic will not take place |
protected _onEnterState ( |
||
$transition |
protected _onExitState ( |
||
$transition |
protected _onTransition ( |
||
$transition |
public add ( string $message = null ) : boolean | ||
$message | string | optional message. this can be used by the persistence adapter to provide extra information in the history of the machine transitions, in this case, about the first adding of this machine to the persistence layer. |
Результат | boolean | true if not persisted before, false otherwise |
public addTransition ( |
||
$transition | ||
$allow_self_transition_by_regex | boolean | optional: to allow regexes to set a self transition. |
Результат | 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. |
protected addTransitionWithoutRegex ( |
||
$transition | ||
Результат | boolean | true in case it was added. false otherwise |
public canTransition ( string $transition_name ) : boolean | ||
$transition_name | string | convention: |
Результат | boolean |
public getContext ( ) : |
||
Результат |
public getCurrentState ( ) : |
||
Результат |
public getInitialState ( boolean $allow_null = false ) : |
||
$allow_null | boolean | optional |
Результат | (or null or Exception, only when statemachine is improperly loaded) |
public getStates ( ) : |
||
Результат |
public getTransition ( string $name ) : |
||
$name | string | convention: |
Результат | or null if not found |
public getTransitions ( ) : |
||
Результат |
public handle ( string $event, string $message = null ) : boolean | ||
$event | string | in case the transition will be triggered by an event code
(mealy machine)
this will also match on the transition name
( |
$message | string | optional message. this can be used by the persistence adapter to be part of the transition history to provide extra information about the transition. |
Результат | boolean | true in case a transition was triggered by the event, false otherwise |
protected handlePossibleNonStatemachineException ( Exception $e, integer $code, |
||
$e | Exception | |
$code | integer | if the exception is not of type Exception, wrap it and use this code. |
$transition | optional. if set, we handle it as a transition exception too so it can be logged or handled |
protected handleTransitionException ( |
||
$transition | ||
$e |
public runToCompletion ( string $message = null ) : integer | ||
$message | string | optional message. this can be used by the persistence adapter to be part of the transition history to provide extra information about the transition. |
Результат | integer | the number of sucessful transitions made. |
public setContext ( |
||
$context |
public transition ( string $transition_name, string $message = null ) : boolean | ||
$transition_name | string | convention: |
$message | string | optional message. this can be used by the persistence adapter to be part of the transition history to provide extra information about the transition. |
Результат | boolean | true if the transition was made |