private function doCheckCanTransition(Transition $transition)
{
try {
// check if we have this transition on the current state.
if (!$this->getCurrentState()->hasTransition($transition->getName())) {
return false;
}
// possible hook so your application can place an extra guard on the
// transition. possible entry~ or exit state type of checks can also
// take place in this hook.
if (!$this->_onCheckCanTransition($transition)) {
return false;
}
// an event handler that is possibly defined on the domain model: onCheckCanTransition
if (!$this->callEventHandler($this->getContext()->getEntity(), 'onCheckCanTransition', $this->getContext()->getIdentifier(), $transition)) {
return false;
}
// this will check the guards defined for the transition: Rule and callable
if (!$transition->can($this->getContext())) {
return false;
}
} catch (Exception $e) {
$this->handlePossibleNonStatemachineException($e, Exception::SM_CAN_FAILED);
}
// if we come here, this acts as a green light to start the transition.
return true;
}