if (!
$asset) { throw new NotFoundHttpException(sprintf('Asset with public path "%s" not found.',
$pathInfo));
} $mediaType =
$this->
getMediaType($asset->publicPath
);
$response =
(new Response( $asset->content,
headers:
$mediaType ?
['Content-Type' =>
$mediaType] :
[],
)) ->
setPublic() ->
setMaxAge(604800
) ->
setImmutable() ->
setEtag($asset->digest
) ;
$event->
setResponse($response);
} public static function getSubscribedEvents(): array
{ return [ // priority higher than RouterListener
KernelEvents::REQUEST =>
[['onKernelRequest', 35
]],
];