/**
*
* @param State $state_from
* @param State $state_to
* @param string $event
* optional: an event name by which this transition can be
* triggered
* @param string $rule
* optional: one or more fully qualified Rule (sub)class name(s)
* to check to see if we are allowed to transition.
* This can actually be a ',' seperated string of multiple rules
* that will be applied as a chained 'and' rule.
* @param string $command
* optional: one or more fully qualified Command (sub)class
* name(s) to execute for a transition.
* This can actually be a ',' seperated string of multiple
* commands that will be executed as a composite.
* @param callable $callable_guard
* optional: a php callable to call. eg: "function(){echo 'closure called';};"
* @param callable $callable_transition
* optional: a php callable to call. eg: "izzum\MyClass::myStaticMethod"
*/
public function __construct(State $state_from, State $state_to, $event = null, $rule = self::RULE_EMPTY, $command = self::COMMAND_EMPTY, $callable_guard = self::CALLABLE_NULL, $callable_transition = self::CALLABLE_NULL)
{
$this->state_from = $state_from;
$this->state_to = $state_to;
$this->setRuleName($rule);
$this->setCommandName($command);
$this->setGuardCallable($callable_guard);
$this->setTransitionCallable($callable_transition);
// setup bidirectional relationship with state this transition
// originates from. only if it's not a regex or final state type
if (!$state_from->isRegex() && !$state_from->isFinal()) {
$state_from->addTransition($this);
}
// set and sanitize event name
$this->setEvent($event);
}