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
8888 return ;
8989 }
9090
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 ' );
9296
9397 Hub::getCurrent ()
9498 ->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
355355 $ this ->assertSame (['route ' => 'sf-route ' ], $ this ->currentScope ->getTags ());
356356 }
357357
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+
358380 public function testOnKernelRequestUserDataAndTagsAreNotSetInSubRequest (): void
359381 {
360382 $ this ->currentHub ->configureScope (Argument::type ('callable ' ))
You can’t perform that action at this time.
0 commit comments