Guards stopped working
Padam87 opened this issue · comments
This commit changed the way guards work. Now they can only stop a transition, but can't explicitly approve it like before. This is a huge BC break.
Previously if a guard returned true, the transition was good to go. Now it has to pass the regular checks too, and those will most likely fail.
There might be nothing to do about this now, but these changes should result in a major version bump in the future.
BC StateMachine for anyone looking
parameters:
finite.state_machine.class: AppBundle\Finite\StateMachine
class StateMachine extends \Finite\StateMachine\StateMachine
{
/**
* {@inheritdoc}
*/
public function can($transition, array $parameters = [])
{
$transition = $transition instanceof TransitionInterface ? $transition : $this->getTransition($transition);
if ($transition->getGuard()) {
return call_user_func($transition->getGuard(), $this);
}
return parent::can($transition, $parameters);
}
}