StateMachineInterface
Reads states, transitions and gates for a domain from data-driven definitions ({@see \Milpa\Workflow\Entities\StateDefinition}, {@see \Milpa\Workflow\Entities\TransitionDefinition}, {@see \Milpa\Workflow\Entities\GateDefinition}) instead of a hardcoded transition graph.
StateMachineInterface::canTransition()
abstract public function canTransition(string $domain, string $fromState, string $toState, Milpa\Workflow\StateMachine\TransitionContext $context): Milpa\Workflow\StateMachine\GateResultChecks whether a transition from `$fromState` to `$toState` is currently possible for `$domain`, evaluating every gate configured on the transition against `$context`.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string | |
| $fromState | string | |
| $toState | string | |
| $context | Milpa\Workflow\StateMachine\TransitionContext |
StateMachineInterface::getAvailableTransitions()
abstract public function getAvailableTransitions(string $domain, string $currentState, Milpa\Workflow\StateMachine\TransitionContext $context): arrayReturns every transition defined from `$currentState`, each paired with the {@see GateResult} of evaluating it against `$context`.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string | |
| $currentState | string | |
| $context | Milpa\Workflow\StateMachine\TransitionContext |
StateMachineInterface::transition()
abstract public function transition(string $domain, string $fromState, string $toState, Milpa\Workflow\StateMachine\TransitionContext $context): Milpa\Workflow\Entities\StateDefinitionExecutes a transition from `$fromState` to `$toState`, throwing when it is not allowed.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string | |
| $fromState | string | |
| $toState | string | |
| $context | Milpa\Workflow\StateMachine\TransitionContext |
Throws
\Milpa\Workflow\Exceptions\TransitionNotAllowedException when the transition is
undefined, disabled, or blocked by a failed gate
StateMachineInterface::findState()
abstract public function findState(string $domain, string $stateCode): ?Milpa\Workflow\Entities\StateDefinitionLooks up a single state by domain and code.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string | |
| $stateCode | string |
StateMachineInterface::getStates()
abstract public function getStates(string $domain): arrayReturns every state defined for a domain, ordered for display.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string |
StateMachineInterface::getInitialState()
abstract public function getInitialState(string $domain): ?Milpa\Workflow\Entities\StateDefinitionReturns the domain's initial state, or null if none is configured.
Parameters
| Name | Type | Description |
|---|---|---|
| $domain | string |