@@ -43,7 +43,7 @@ public function __construct(
4343 private readonly RequestStack $ requestStack ,
4444 private readonly Stopwatch $ stopwatch ,
4545 private readonly bool $ cliMode ,
46- private readonly UrlGeneratorInterface $ urlGenerator ,
46+ private readonly ? UrlGeneratorInterface $ urlGenerator = null ,
4747 ) {
4848 $ this ->profiles = new \SplObjectStorage ();
4949 $ this ->parents = new \SplObjectStorage ();
@@ -140,12 +140,14 @@ public function profile(ConsoleTerminateEvent $event): void
140140 $ p = $ this ->profiles [$ r ];
141141 $ this ->profiler ->saveProfile ($ p );
142142
143- $ token = $ p ->getToken ();
144- $ output ?->writeln(sprintf (
145- 'See profile <href=%s>%s</> ' ,
146- $ this ->urlGenerator ->generate ('_profiler ' , ['token ' => $ token ], UrlGeneratorInterface::ABSOLUTE_URL ),
147- $ token
148- ));
143+ if ($ this ->urlGenerator && $ output ) {
144+ $ token = $ p ->getToken ();
145+ $ output ->writeln (sprintf (
146+ 'See profile <href=%s>%s</> ' ,
147+ $ this ->urlGenerator ->generate ('_profiler ' , ['token ' => $ token ], UrlGeneratorInterface::ABSOLUTE_URL ),
148+ $ token
149+ ));
150+ }
149151 }
150152
151153 $ this ->profiles = new \SplObjectStorage ();
0 commit comments