Skip to content

Commit 1f07d75

Browse files
authored
[9.x] Lazy load queue commands (#38479)
* use class name for command registration * assign defaultName for lazy loading
1 parent 67f0a12 commit 1f07d75

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ protected function registerQueueListenCommand()
681681
*/
682682
protected function registerQueueMonitorCommand()
683683
{
684-
$this->app->singleton('command.queue.monitor', function ($app) {
684+
$this->app->singleton(QueueMonitorCommand::class, function ($app) {
685685
return new QueueMonitorCommand($app['queue'], $app['events']);
686686
});
687687
}
@@ -705,7 +705,7 @@ protected function registerQueuePruneBatchesCommand()
705705
*/
706706
protected function registerQueuePruneFailedJobsCommand()
707707
{
708-
$this->app->singleton('command.queue.prune-failed-jobs', function () {
708+
$this->app->singleton(QueuePruneFailedJobsCommand::class, function () {
709709
return new QueuePruneFailedJobsCommand;
710710
});
711711
}

src/Illuminate/Queue/Console/MonitorCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ class MonitorCommand extends Command
1919
{queues : The names of the queues to monitor}
2020
{--max=1000 : The maximum number of jobs that can be on the queue before an event is dispatched}';
2121

22+
/**
23+
* The name of the console command.
24+
*
25+
* This name is used to identify the command during lazy loading.
26+
*
27+
* @var string|null
28+
*/
29+
protected static $defaultName = 'queue:monitor';
30+
2231
/**
2332
* The console command description.
2433
*

src/Illuminate/Queue/Console/PruneFailedJobsCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ class PruneFailedJobsCommand extends Command
1616
protected $signature = 'queue:prune-failed
1717
{--hours=24 : The number of hours to retain failed jobs data}';
1818

19+
/**
20+
* The name of the console command.
21+
*
22+
* This name is used to identify the command during lazy loading.
23+
*
24+
* @var string|null
25+
*/
26+
protected static $defaultName = 'queue:prune-failed';
27+
1928
/**
2029
* The console command description.
2130
*

0 commit comments

Comments
 (0)