Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guards stopped working #134

Open
Padam87 opened this issue May 8, 2017 · 2 comments
Open

Guards stopped working #134

Padam87 opened this issue May 8, 2017 · 2 comments

Comments

@Padam87
Copy link
Contributor

Padam87 commented May 8, 2017

f6b1886

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.

@Padam87
Copy link
Contributor Author

Padam87 commented May 8, 2017

#107

@Padam87
Copy link
Contributor Author

Padam87 commented May 8, 2017

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);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant