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

Make using allowAllTransitions() less cumbersome #265

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

jonjakoblich
Copy link
Contributor

One of the great things about this package is that it will automatically load states that are placed in the same directory as the abstract base state class. There is no need to manually register concrete states in the same directory...with one exception - the allowAllTransitions() config method.

Currently the docs show the following example:

abstract class PaymentState extends State
{
    // …

    public static function config(): StateConfig
    {
        return parent::config()
            ->allowAllTransitions();
    }
}

However, this code is not possible to execute without it throwing a Spatie\ModelStates\Exceptions\InvalidConfig exception.

My pull request updates the allowAllTransitions() method to automatically register the concrete state classes in the same directory as the abstract base state class, thereby making the above code work as a user might expect.

This eliminates the cumbersome overhead of explicitly registering every state in the same directory when using allowAlltransitions().

…directory when using allowAllTransitions method
@freekmurze freekmurze merged commit 2ca065e into spatie:main Dec 11, 2024
1 check passed
@freekmurze
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants