@@ -53,8 +53,8 @@ protected function configure(): void {
53
53
->setDescription ('Run a background job worker ' )
54
54
->addArgument (
55
55
'job-classes ' ,
56
- InputArgument::OPTIONAL ,
57
- 'The classes of the jobs to look for in the database, comma-separated '
56
+ InputArgument::OPTIONAL | InputArgument:: IS_ARRAY ,
57
+ 'The classes of the jobs to look for in the database '
58
58
)
59
59
->addOption (
60
60
'once ' ,
@@ -73,25 +73,11 @@ protected function configure(): void {
73
73
}
74
74
75
75
protected function execute (InputInterface $ input , OutputInterface $ output ): int {
76
- $ jobClassesString = $ input ->getArgument ('job-classes ' );
77
- // only keep non-empty strings
78
- $ jobClasses = $ jobClassesString === null
79
- ? null
80
- : array_filter (
81
- explode (', ' , $ jobClassesString ),
82
- static function (string $ jobClass ) {
83
- return strlen ($ jobClass ) > 0 ;
84
- }
85
- );
76
+ $ jobClasses = $ input ->getArgument ('job-classes ' );
77
+ $ jobClasses = empty ($ jobClasses ) ? null : $ jobClasses ;
86
78
87
79
if ($ jobClasses !== null ) {
88
- // no class
89
- if (count ($ jobClasses ) === 0 ) {
90
- $ output ->writeln ('<error>Invalid job class list supplied</error> ' );
91
- return 1 ;
92
- }
93
-
94
- // at least one invalid class
80
+ // at least one class is invalid
95
81
foreach ($ jobClasses as $ jobClass ) {
96
82
if (!class_exists ($ jobClass )) {
97
83
$ output ->writeln ('<error>Invalid job class: ' . $ jobClass . '</error> ' );
@@ -115,10 +101,10 @@ static function (string $jobClass) {
115
101
$ job = $ this ->jobList ->getNext (false , $ jobClasses );
116
102
if (!$ job ) {
117
103
if ($ input ->getOption ('once ' ) === true ) {
118
- if ($ jobClassesString === null ) {
104
+ if ($ jobClasses === null ) {
119
105
$ output ->writeln ('No job is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
120
106
} else {
121
- $ output ->writeln ('No job of classes ' . $ jobClassesString . ' is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
107
+ $ output ->writeln ('No job of classes [ ' . implode ( ' , ' , $ jobClasses ) . '] is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
122
108
}
123
109
$ output ->writeln ('Exiting... ' , OutputInterface::VERBOSITY_VERBOSE );
124
110
break ;
0 commit comments