-
Notifications
You must be signed in to change notification settings - Fork 222
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
Improve "Illuminate\Console\Scheduling\Schedule" configuration #28
Comments
Thanks @aik099 . I will look into this. Definitely sounds like an improvement. |
Have you tried this ? For some reason resolving callback is not triggered for Illuminate\Console\Scheduling\Schedule. |
I haven't tried that myself. Are you doing |
Yup, tried it in boot method. Looks like the Schedule class is not resolved until its required. Will have to dig deeper to figure out whats going on. |
Debugging revealed, that $this->app->instance(
Schedule::class, $schedule = new Schedule($this->app[Cache::class])
); If that could would be written differently, e.g. via |
Replacing above code (in Laravel core) with this one does the trick: $this->app->singleton(Schedule::class, function ($app) {
return new Schedule($app[Cache::class]);
});
$schedule = $this->app->make(Schedule::class); I've created PR into Laravel 5.5: laravel/framework#20933 |
At least you can simplify existing code (would work the same way, but look better) by moving code from |
This is really nice. I guess I will have to maintain two separate branches for 5.4 and 5.5 as I dont think this will be merged to 5.4 branch. Thanks for your insight and help. I might use your expertise in one another issue I am facing here |
Since 5.5 is already released, then my change would only be in 5.5.x release. So having 2 branches won't really do the trick. Maybe you'll have to do some feature detection and decide which code to run. |
I have incorporated the changes in latest releases for both 5.4 and 5.5 branches. Thanks for all your help @aik099. |
Right now in the
\Studio\Totem\Providers\ConsoleServiceProvider::register
method thebooted
event is being listened and then app is run in console, then new schedules are added into application.Proposing to simplify this by:
\Studio\Totem\Providers\ConsoleServiceProvider::boot
method instead of\Studio\Totem\Providers\ConsoleServiceProvider::register
method$this->app->resolving(Illuminate\Console\Scheduling\Schedule::class, function (...
This way whoever wants the schedule class would get it with all schedules already added.
Not sure though how this thing could be tested or if
resolving
events are triggered in unit tests.The text was updated successfully, but these errors were encountered: