File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,11 @@ public function onKernelController(FilterControllerEvent $event): void
88
88
return ;
89
89
}
90
90
91
- $ matchedRoute = $ event ->getRequest ()->attributes ->get ('_route ' );
91
+ if (! $ event ->getRequest ()->attributes ->has ('_route ' )) {
92
+ return ;
93
+ }
94
+
95
+ $ matchedRoute = (string ) $ event ->getRequest ()->attributes ->get ('_route ' );
92
96
93
97
Hub::getCurrent ()
94
98
->configureScope (function (Scope $ scope ) use ($ matchedRoute ): void {
Original file line number Diff line number Diff line change @@ -355,6 +355,28 @@ public function testOnKernelControllerAddsRouteTag(): void
355
355
$ this ->assertSame (['route ' => 'sf-route ' ], $ this ->currentScope ->getTags ());
356
356
}
357
357
358
+ public function testOnKernelControllerRouteTagIsNotSetIfRequestDoesNotHaveARoute (): void
359
+ {
360
+ $ this ->currentHub ->configureScope (Argument::type ('callable ' ))
361
+ ->shouldNotBeCalled ();
362
+
363
+ $ request = new Request ();
364
+ $ event = $ this ->prophesize (FilterControllerEvent::class);
365
+
366
+ $ event ->isMasterRequest ()
367
+ ->willReturn (true );
368
+ $ event ->getRequest ()
369
+ ->willReturn ($ request );
370
+
371
+ $ listener = new RequestListener (
372
+ $ this ->currentHub ->reveal (),
373
+ $ this ->prophesize (TokenStorageInterface::class)->reveal (),
374
+ $ this ->prophesize (AuthorizationCheckerInterface::class)->reveal ()
375
+ );
376
+
377
+ $ listener ->onKernelController ($ event ->reveal ());
378
+ }
379
+
358
380
public function testOnKernelRequestUserDataAndTagsAreNotSetInSubRequest (): void
359
381
{
360
382
$ this ->currentHub ->configureScope (Argument::type ('callable ' ))
You can’t perform that action at this time.
0 commit comments