protected function addTransitionWithoutRegex(Transition $transition)
{
// don't allow transitions from a final state
if ($transition->getStateFrom()->isFinal()) {
return false;
}
// add the transition only if it already exists (no overwrites)
if ($this->getTransition($transition->getName()) !== null) {
return false;
}
$this->transitions[$transition->getName()] = $transition;
$from = $transition->getStateFrom();
// adds state only if it does not already exist (no overwrites)
$this->addState($from);
/*
* transitions create bidirectional references to the States
* when they are made, but here the States that are set on the machine
* can actually be different instances from different transitions (eg:
* a->b and a->c => we now have two State instances of a)
* we therefore need to merge the transitions on the existing states.
* The LoaderArray class does this for us by default, but we do it here
* too, just in case a client decides to call the 'addTransition' method
* directly without a loader.
*/
//get the state known to the machine, to prevent possible bug where client
//creates 2 different state instances with different configs. we won't know
//how to resolve this anyway, so just pick the existing state (first in wins)
$state = $this->getState($from->getName());
// adds transition only if it does not already exist (no overwrites)
$state->addTransition($transition);
$to = $transition->getStateTo();
// adds state only if it dooes not already exist (no overwrites)
$this->addState($to);
return true;
}