@@ -128,15 +128,17 @@ private function registerRoutes(): void
128128
129129 private function registerDashboard (): void
130130 {
131- app ('events ' )->listen (TaskCreated::class, function (TaskCreated $ event ) {
131+ $ events = $ this ->app ['events ' ];
132+
133+ $ events ->listen (TaskCreated::class, function (TaskCreated $ event ) {
132134 if (CloudTasks::dashboardDisabled ()) {
133135 return ;
134136 }
135137
136138 DashboardService::make ()->add ($ event ->queue , $ event ->task );
137139 });
138140
139- app ( ' events ' ) ->listen (JobFailed::class, function (JobFailed $ event ) {
141+ $ events ->listen (JobFailed::class, function (JobFailed $ event ) {
140142 if (!$ event ->job instanceof CloudTasksJob) {
141143 return ;
142144 }
@@ -149,52 +151,58 @@ private function registerDashboard(): void
149151 );
150152 });
151153
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 ) {
154156 return ;
155157 }
156158
157- if ($ event -> job instanceof CloudTasksJob ) {
159+ if (CloudTasks:: dashboardEnabled () ) {
158160 DashboardService::make ()->markAsRunning ($ event ->job ->uuid ());
159161 }
160162 });
161163
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) {
166166 return ;
167167 }
168168
169- if ($ event ->job instanceof CloudTasksJob) {
169+ data_set ($ event ->job ->job , 'internal.processed ' , true );
170+
171+ if (CloudTasks::dashboardEnabled ()) {
170172 DashboardService::make ()->markAsSuccessful ($ event ->job ->uuid ());
171173 }
172174 });
173175
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) {
178178 return ;
179179 }
180180
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+ }
182186 });
183187
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 ) {
186190 return ;
187191 }
188192
189- DashboardService::make ()->markAsFailed ($ event );
193+ if (CloudTasks::dashboardEnabled ()) {
194+ DashboardService::make ()->markAsFailed ($ event );
195+ }
190196 });
191197
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 ) {
194200 return ;
195201 }
196202
197- DashboardService::make ()->markAsReleased ($ event );
203+ if (CloudTasks::dashboardEnabled ()) {
204+ DashboardService::make ()->markAsReleased ($ event );
205+ }
198206 });
199207 }
200208}
0 commit comments