@@ -128,15 +128,17 @@ private function registerRoutes(): void
128
128
129
129
private function registerDashboard (): void
130
130
{
131
- app ('events ' )->listen (TaskCreated::class, function (TaskCreated $ event ) {
131
+ $ events = $ this ->app ['events ' ];
132
+
133
+ $ events ->listen (TaskCreated::class, function (TaskCreated $ event ) {
132
134
if (CloudTasks::dashboardDisabled ()) {
133
135
return ;
134
136
}
135
137
136
138
DashboardService::make ()->add ($ event ->queue , $ event ->task );
137
139
});
138
140
139
- app ( ' events ' ) ->listen (JobFailed::class, function (JobFailed $ event ) {
141
+ $ events ->listen (JobFailed::class, function (JobFailed $ event ) {
140
142
if (!$ event ->job instanceof CloudTasksJob) {
141
143
return ;
142
144
}
@@ -149,52 +151,58 @@ private function registerDashboard(): void
149
151
);
150
152
});
151
153
152
- app ( ' events ' ) ->listen (JobProcessing::class, function (JobProcessing $ event ) {
153
- if (!CloudTasks:: dashboardEnabled () ) {
154
+ $ events ->listen (JobProcessing::class, function (JobProcessing $ event ) {
155
+ if (!$ event -> job instanceof CloudTasksJob ) {
154
156
return ;
155
157
}
156
158
157
- if ($ event -> job instanceof CloudTasksJob ) {
159
+ if (CloudTasks:: dashboardEnabled () ) {
158
160
DashboardService::make ()->markAsRunning ($ event ->job ->uuid ());
159
161
}
160
162
});
161
163
162
- app ('events ' )->listen (JobProcessed::class, function (JobProcessed $ event ) {
163
- data_set ($ event ->job ->job , 'internal.processed ' , true );
164
-
165
- if (!CloudTasks::dashboardEnabled ()) {
164
+ $ events ->listen (JobProcessed::class, function (JobProcessed $ event ) {
165
+ if (!$ event ->job instanceof CloudTasksJob) {
166
166
return ;
167
167
}
168
168
169
- if ($ event ->job instanceof CloudTasksJob) {
169
+ data_set ($ event ->job ->job , 'internal.processed ' , true );
170
+
171
+ if (CloudTasks::dashboardEnabled ()) {
170
172
DashboardService::make ()->markAsSuccessful ($ event ->job ->uuid ());
171
173
}
172
174
});
173
175
174
- app ('events ' )->listen (JobExceptionOccurred::class, function (JobExceptionOccurred $ event ) {
175
- data_set ($ event ->job ->job , 'internal.errored ' , true );
176
-
177
- if (!CloudTasks::dashboardEnabled ()) {
176
+ $ events ->listen (JobExceptionOccurred::class, function (JobExceptionOccurred $ event ) {
177
+ if (!$ event ->job instanceof CloudTasksJob) {
178
178
return ;
179
179
}
180
180
181
- DashboardService::make ()->markAsError ($ event );
181
+ data_set ($ event ->job ->job , 'internal.errored ' , true );
182
+
183
+ if (CloudTasks::dashboardEnabled ()) {
184
+ DashboardService::make ()->markAsError ($ event );
185
+ }
182
186
});
183
187
184
- app ( ' events ' ) ->listen (JobFailed::class, function ($ event ) {
185
- if (!CloudTasks:: dashboardEnabled () ) {
188
+ $ events ->listen (JobFailed::class, function ($ event ) {
189
+ if (!$ event -> job instanceof CloudTasksJob ) {
186
190
return ;
187
191
}
188
192
189
- DashboardService::make ()->markAsFailed ($ event );
193
+ if (CloudTasks::dashboardEnabled ()) {
194
+ DashboardService::make ()->markAsFailed ($ event );
195
+ }
190
196
});
191
197
192
- app ( ' events ' ) ->listen (JobReleased::class, function (JobReleased $ event ) {
193
- if (!CloudTasks:: dashboardEnabled () ) {
198
+ $ events ->listen (JobReleased::class, function (JobReleased $ event ) {
199
+ if (!$ event -> job instanceof CloudTasksJob ) {
194
200
return ;
195
201
}
196
202
197
- DashboardService::make ()->markAsReleased ($ event );
203
+ if (CloudTasks::dashboardEnabled ()) {
204
+ DashboardService::make ()->markAsReleased ($ event );
205
+ }
198
206
});
199
207
}
200
208
}
0 commit comments