throw new BadRequestHttpException($e->
getMessage(),
$e,
$e->
getCode());
} } } /**
* After a sub-request is done, we need to reset the routing context to the parent request so that the URL generator
* operates on the correct context again.
*/
public function onKernelFinishRequest(): void
{ $this->
setCurrentRequest($this->requestStack->
getParentRequest());
} public function onKernelRequest(RequestEvent
$event): void
{ $request =
$event->
getRequest();
$this->
setCurrentRequest($request);
if ($request->attributes->
has('_controller'
)) { // routing is already done
return;
}