Skip to content

Commit

Permalink
Resolve the Schedule class from the container instead of DI, fixes #30
Browse files Browse the repository at this point in the history
The Schedule class is resolved from the Container with the global app() function when needed in the
ScheduleList::all method instead of Dependecy injection in the construction.
This is to make sure that Laravel has resolved the class itself and filled in with all schduled tasks
and we get the same instance.
  • Loading branch information
hmazter committed Apr 9, 2019
1 parent 7b60b7c commit 47e11df
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/ScheduleList.php
Expand Up @@ -10,23 +10,16 @@

class ScheduleList
{
/**
* @var Schedule
*/
private $schedule;

/**
* @var ConsoleKernel
*/
private $consoleKernel;

/**
* @param Schedule $schedule
* @param ConsoleKernel $consoleKernel
*/
public function __construct(Schedule $schedule, ConsoleKernel $consoleKernel)
public function __construct(ConsoleKernel $consoleKernel)
{
$this->schedule = $schedule;
$this->consoleKernel = $consoleKernel;
}

Expand All @@ -38,7 +31,7 @@ public function all(): array
$events = [];

/** @var Event $event */
foreach ($this->schedule->events() as $event) {
foreach (app(Schedule::class)->events() as $event) {
$fullCommand = $event->buildCommand();

if ($event instanceof CallbackEvent) {
Expand Down

0 comments on commit 47e11df

Please sign in to comment.