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

[6.x] Added Macroable trait to Illuminate\Console\Scheduling\Schedule class #31354

Merged
merged 1 commit into from Feb 5, 2020
Merged

[6.x] Added Macroable trait to Illuminate\Console\Scheduling\Schedule class #31354

merged 1 commit into from Feb 5, 2020

Conversation

ryangjchandler
Copy link
Contributor

@ryangjchandler ryangjchandler commented Feb 4, 2020

This PR simply adds the Macroable trait to the Illuminate\Console\Scheduling\Schedule class, allowing developers, both application and package, to add custom methods to the Schedule class.

The main benefit I see here is that third-party package developers can add methods to the Schedule class that will schedule commands / closures from their package, letting the package-user to optionally enable those scheduled commands by calling the macro'd function. This would act in the same way as many packages create Route macros to register routes.

There won't be any breaking changes here, or any conflicts that I can see as the Schedule class did not have any magic __call() or __callStatic() methods to begin with.

This trait has already been added to the Illuminate\Console\Scheduling\Event class, can't see any reason why it can't be added to the scheduler.

@taylorotwell
Copy link
Member

What kind of custom methods do you find yourself wanting to add?

@ryangjchandler
Copy link
Contributor Author

ryangjchandler commented Feb 5, 2020

What kind of custom methods do you find yourself wanting to add?

I've had times when developing packages that I'd like to add some optional scheduled tasks to prune a database table for example, with a macro, the end user can simply add Schedule::macroName() or $schedule->macroName() to their Kernel class, without having to worry about the actual occurrence of the command themselves.

I suppose it has the same reasoning as macro'ing methods onto the Route facade so that custom package routes can optionally be registered.

@taylorotwell taylorotwell merged commit 14972d5 into laravel:6.x Feb 5, 2020
@ryangjchandler ryangjchandler deleted the macroable-scheduler branch February 5, 2020 15:19
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.

None yet

2 participants