2020use Barryvdh \Debugbar \Storage \SocketStorage ;
2121use Barryvdh \Debugbar \Storage \FilesystemStorage ;
2222use Barryvdh \Debugbar \Support \Clockwork \ClockworkCollector ;
23- use Barryvdh \Debugbar \Support \RequestIdGenerator ;
2423use DebugBar \Bridge \MonologCollector ;
24+ use DebugBar \Bridge \SwiftMailer \SwiftLogCollector ;
25+ use DebugBar \Bridge \SwiftMailer \SwiftMailCollector ;
2526use DebugBar \Bridge \Symfony \SymfonyMailCollector ;
2627use DebugBar \DataCollector \ConfigCollector ;
2728use DebugBar \DataCollector \DataCollectorInterface ;
@@ -126,7 +127,6 @@ public function __construct($app = null)
126127 if ($ this ->is_lumen ) {
127128 $ this ->version = Str::betweenFirst ($ app ->version (), '( ' , ') ' );
128129 }
129- $ this ->setRequestIdGenerator (new RequestIdGenerator ());
130130 }
131131
132132 /**
@@ -496,17 +496,27 @@ function (\Illuminate\Database\Events\ConnectionEstablished $event) {
496496
497497 if ($ this ->shouldCollect ('mail ' , true ) && class_exists ('Illuminate\Mail\MailServiceProvider ' ) && $ events ) {
498498 try {
499- $ mailCollector = new SymfonyMailCollector ();
499+ if ($ this ->checkVersion ('9.0 ' )) {
500+ $ mailCollector = new SymfonyMailCollector ();
501+ $ events ->listen (function (MessageSent $ event ) use ($ mailCollector ) {
502+ $ mailCollector ->addSymfonyMessage ($ event ->sent ->getSymfonySentMessage ());
503+ });
504+ } else {
505+ $ mailer = $ app ['mailer ' ]->getSwiftMailer ();
506+ $ mailCollector = new SwiftMailCollector ($ mailer );
507+
508+ if ($ config ->get ('debugbar.options.mail.show_body ' ) && $ this ->hasCollector ('messages ' )) {
509+ $ this ['messages ' ]->aggregate (new SwiftLogCollector ($ mailer ));
510+ }
511+ }
512+
500513 $ this ->addCollector ($ mailCollector );
501- $ events ->listen (function (MessageSent $ event ) use ($ mailCollector ) {
502- $ mailCollector ->addSymfonyMessage ($ event ->sent ->getSymfonySentMessage ());
503- });
504514
505515 if ($ config ->get ('debugbar.options.mail.show_body ' ) || $ config ->get ('debugbar.options.mail.full_log ' )) {
506516 $ mailCollector ->showMessageBody ();
507517 }
508518
509- if ($ this ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.mail.timeline ' )) {
519+ if ($ this ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.mail.timeline ' ) && $ this -> checkVersion ( ' 9.0 ' ) ) {
510520 $ transport = $ app ['mailer ' ]->getSymfonyTransport ();
511521 $ app ['mailer ' ]->setSymfonyTransport (new class ($ transport , $ this ) extends AbstractTransport{
512522 private $ originalTransport ;
@@ -537,7 +547,9 @@ public function __toString(): string
537547 });
538548 }
539549 } catch (Exception $ e ) {
540- $ this ->addCollectorException ('Cannot add SymfonyMailCollector ' , $ e );
550+ $ this ->addCollectorException (
551+ 'Cannot add ' .($ this ->checkVersion ('9.0 ' )?'SymfonyMailCollector ' :'SwiftMailCollector ' ), $ e
552+ );
541553 }
542554 }
543555
@@ -549,9 +561,6 @@ public function __toString(): string
549561 $ this ->addCollectorException ('Cannot add LogsCollector ' , $ e );
550562 }
551563 }
552- if ($ this ->shouldCollect ('files ' , false )) {
553- $ this ->addCollector (new FilesCollector ($ app ));
554- }
555564
556565 if ($ this ->shouldCollect ('auth ' , false )) {
557566 try {
0 commit comments