@@ -138,9 +138,6 @@ public function boot()
138
138
return ;
139
139
}
140
140
141
- /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
142
- $ debugbar = $ this ;
143
-
144
141
/** @var Application $app */
145
142
$ app = $ this ->app ;
146
143
@@ -158,7 +155,7 @@ public function boot()
158
155
set_error_handler ([$ this , 'handleError ' ]);
159
156
}
160
157
161
- $ this ->selectStorage ($ debugbar );
158
+ $ this ->selectStorage ($ this );
162
159
163
160
if ($ this ->shouldCollect ('phpinfo ' , true )) {
164
161
$ this ->addCollector (new PhpInfoCollector ());
@@ -177,41 +174,38 @@ public function boot()
177
174
$ this ->addCollector (new TimeDataCollector ($ startTime ));
178
175
179
176
if ($ config ->get ('debugbar.options.time.memory_usage ' )) {
180
- $ debugbar ['time ' ]->showMemoryUsage ();
177
+ $ this ['time ' ]->showMemoryUsage ();
181
178
}
182
179
183
180
if (! $ this ->isLumen () && $ startTime ) {
184
181
$ app ->booted (
185
- function () use ($ debugbar , $ startTime ) {
186
- $ debugbar ->addMeasure ('Booting ' , $ startTime , microtime (true ), [], 'time ' );
182
+ function () use ($ startTime ) {
183
+ $ this ->addMeasure ('Booting ' , $ startTime , microtime (true ), [], 'time ' );
187
184
}
188
185
);
189
186
}
190
187
191
- $ debugbar ->startMeasure ('application ' , 'Application ' , 'time ' );
188
+ $ this ->startMeasure ('application ' , 'Application ' , 'time ' );
192
189
}
193
190
194
191
if ($ this ->shouldCollect ('memory ' , true )) {
195
- $ memoryCollector = new MemoryCollector ();
196
- if (method_exists ($ memoryCollector , 'setPrecision ' )) {
197
- $ memoryCollector ->setPrecision ($ config ->get ('debugbar.options.memory.precision ' , 0 ));
198
- }
192
+ $ this ->addCollector (new MemoryCollector ());
193
+ $ this ['memory ' ]->setPrecision ($ config ->get ('debugbar.options.memory.precision ' , 0 ));
194
+
199
195
if (function_exists ('memory_reset_peak_usage ' ) && $ config ->get ('debugbar.options.memory.reset_peak ' )) {
200
196
memory_reset_peak_usage ();
201
197
}
202
198
if ($ config ->get ('debugbar.options.memory.with_baseline ' )) {
203
- $ memoryCollector ->resetMemoryBaseline ();
199
+ $ this [ ' memory ' ] ->resetMemoryBaseline ();
204
200
}
205
- $ this ->addCollector ($ memoryCollector );
206
201
}
207
202
208
203
if ($ this ->shouldCollect ('exceptions ' , true )) {
209
204
try {
210
- $ exceptionCollector = new ExceptionsCollector ();
211
- $ exceptionCollector ->setChainExceptions (
205
+ $ this -> addCollector ( new ExceptionsCollector () );
206
+ $ this [ ' exceptions ' ] ->setChainExceptions (
212
207
$ config ->get ('debugbar.options.exceptions.chain ' , true )
213
208
);
214
- $ this ->addCollector ($ exceptionCollector );
215
209
} catch (Exception $ e ) {
216
210
}
217
211
}
@@ -354,53 +348,53 @@ function (\Illuminate\Database\Events\QueryExecuted $query) {
354
348
try {
355
349
$ events ->listen (
356
350
\Illuminate \Database \Events \TransactionBeginning::class,
357
- function ($ transaction ) use ( $ queryCollector ) {
358
- $ queryCollector ->collectTransactionEvent ('Begin Transaction ' , $ transaction ->connection );
351
+ function ($ transaction ) {
352
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Begin Transaction ' , $ transaction ->connection );
359
353
}
360
354
);
361
355
362
356
$ events ->listen (
363
357
\Illuminate \Database \Events \TransactionCommitted::class,
364
- function ($ transaction ) use ( $ queryCollector ) {
365
- $ queryCollector ->collectTransactionEvent ('Commit Transaction ' , $ transaction ->connection );
358
+ function ($ transaction ) {
359
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Commit Transaction ' , $ transaction ->connection );
366
360
}
367
361
);
368
362
369
363
$ events ->listen (
370
364
\Illuminate \Database \Events \TransactionRolledBack::class,
371
- function ($ transaction ) use ( $ queryCollector ) {
372
- $ queryCollector ->collectTransactionEvent ('Rollback Transaction ' , $ transaction ->connection );
365
+ function ($ transaction ) {
366
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Rollback Transaction ' , $ transaction ->connection );
373
367
}
374
368
);
375
369
376
370
$ events ->listen (
377
371
'connection.*.beganTransaction ' ,
378
- function ($ event , $ params ) use ( $ queryCollector ) {
379
- $ queryCollector ->collectTransactionEvent ('Begin Transaction ' , $ params [0 ]);
372
+ function ($ event , $ params ) {
373
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Begin Transaction ' , $ params [0 ]);
380
374
}
381
375
);
382
376
383
377
$ events ->listen (
384
378
'connection.*.committed ' ,
385
- function ($ event , $ params ) use ( $ queryCollector ) {
386
- $ queryCollector ->collectTransactionEvent ('Commit Transaction ' , $ params [0 ]);
379
+ function ($ event , $ params ) {
380
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Commit Transaction ' , $ params [0 ]);
387
381
}
388
382
);
389
383
390
384
$ events ->listen (
391
385
'connection.*.rollingBack ' ,
392
- function ($ event , $ params ) use ( $ queryCollector ) {
393
- $ queryCollector ->collectTransactionEvent ('Rollback Transaction ' , $ params [0 ]);
386
+ function ($ event , $ params ) {
387
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Rollback Transaction ' , $ params [0 ]);
394
388
}
395
389
);
396
390
397
391
$ events ->listen (
398
- function (\Illuminate \Database \Events \ConnectionEstablished $ event ) use ( $ queryCollector ) {
399
- $ queryCollector ->collectTransactionEvent ('Connection Established ' , $ event ->connection );
392
+ function (\Illuminate \Database \Events \ConnectionEstablished $ event ) {
393
+ $ this [ ' queries ' ] ->collectTransactionEvent ('Connection Established ' , $ event ->connection );
400
394
401
395
if (app ('config ' )->get ('debugbar.options.db.memory_usage ' )) {
402
- $ event ->connection ->beforeExecuting (function () use ( $ queryCollector ) {
403
- $ queryCollector ->startMemoryUsage ();
396
+ $ event ->connection ->beforeExecuting (function () {
397
+ $ this [ ' queries ' ] ->startMemoryUsage ();
404
398
});
405
399
}
406
400
}
@@ -433,17 +427,16 @@ function (\Illuminate\Database\Events\ConnectionEstablished $event) use ($queryC
433
427
434
428
if ($ this ->shouldCollect ('mail ' , true ) && class_exists ('Illuminate\Mail\MailServiceProvider ' ) && $ events ) {
435
429
try {
436
- $ mailCollector = new SymfonyMailCollector ();
437
- $ this ->addCollector ($ mailCollector );
438
- $ events ->listen (function (MessageSent $ event ) use ($ mailCollector ) {
439
- $ mailCollector ->addSymfonyMessage ($ event ->sent ->getSymfonySentMessage ());
430
+ $ this ->addCollector (new SymfonyMailCollector ());
431
+ $ events ->listen (function (MessageSent $ event ) {
432
+ $ this ['mail ' ]->addSymfonyMessage ($ event ->sent ->getSymfonySentMessage ());
440
433
});
441
434
442
435
if ($ config ->get ('debugbar.options.mail.full_log ' )) {
443
- $ mailCollector ->showMessageDetail ();
436
+ $ this [ ' mail ' ] ->showMessageDetail ();
444
437
}
445
438
446
- if ($ debugbar ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.mail.timeline ' )) {
439
+ if ($ this ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.mail.timeline ' )) {
447
440
$ transport = $ app ['mailer ' ]->getSymfonyTransport ();
448
441
$ app ['mailer ' ]->setSymfonyTransport (new class ($ transport , $ this ) extends AbstractTransport{
449
442
private $ originalTransport ;
@@ -493,12 +486,11 @@ public function __toString(): string
493
486
if ($ this ->shouldCollect ('auth ' , false )) {
494
487
try {
495
488
$ guards = $ config ->get ('auth.guards ' , []);
496
- $ authCollector = new MultiAuthCollector ($ app ['auth ' ], $ guards );
489
+ $ this -> addCollector ( new MultiAuthCollector ($ app ['auth ' ], $ guards) );
497
490
498
- $ authCollector ->setShowName (
491
+ $ this [ ' auth ' ] ->setShowName (
499
492
$ config ->get ('debugbar.options.auth.show_name ' )
500
493
);
501
- $ this ->addCollector ($ authCollector );
502
494
} catch (Exception $ e ) {
503
495
$ this ->addCollectorException ('Cannot add AuthCollector ' , $ e );
504
496
}
@@ -516,9 +508,8 @@ public function __toString(): string
516
508
try {
517
509
$ collectValues = $ config ->get ('debugbar.options.cache.values ' , true );
518
510
$ startTime = $ app ['request ' ]->server ('REQUEST_TIME_FLOAT ' );
519
- $ cacheCollector = new CacheCollector ($ startTime , $ collectValues );
520
- $ this ->addCollector ($ cacheCollector );
521
- $ events ->subscribe ($ cacheCollector );
511
+ $ this ->addCollector (new CacheCollector ($ startTime , $ collectValues ));
512
+ $ events ->subscribe ($ this ['cache ' ]);
522
513
} catch (Exception $ e ) {
523
514
$ this ->addCollectorException ('Cannot add CacheCollector ' , $ e );
524
515
}
0 commit comments