@@ -43,7 +43,7 @@ public function __construct(
43
43
private readonly RequestStack $ requestStack ,
44
44
private readonly Stopwatch $ stopwatch ,
45
45
private readonly bool $ cliMode ,
46
- private readonly UrlGeneratorInterface $ urlGenerator ,
46
+ private readonly ? UrlGeneratorInterface $ urlGenerator = null ,
47
47
) {
48
48
$ this ->profiles = new \SplObjectStorage ();
49
49
$ this ->parents = new \SplObjectStorage ();
@@ -140,12 +140,14 @@ public function profile(ConsoleTerminateEvent $event): void
140
140
$ p = $ this ->profiles [$ r ];
141
141
$ this ->profiler ->saveProfile ($ p );
142
142
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
+ }
149
151
}
150
152
151
153
$ this ->profiles = new \SplObjectStorage ();
0 commit comments