symfony - Symfony2 app.request.get('_route') is empty when throw new AccessDeniedException -


i'm working on implementing role based admin application. have custom voter , @ point i'm doing like:

if($role && voterinterface::access_granted !== $voteresult) {     throw new accessdeniedexception('unauthorized access!'); } 

and result custom error403.html.twig template rendered. far good.

the error403 template extends main template in @ point i'm building menu using app.request.get('_route') generating links.

the problem app.request.get('_route') null.

xdebug-ing issue i've noticed somehow $request->attributes->parameters array not contain _route or _route_params keys.

any thoughts?

the problem symfony uses sub-request rendering error pages. doesn't need router , have not exatly same request object in master request.

github issue

https://github.com/symfony/symfony/issues/5804

same question on so

app.request.attributes.get('_route') empty when override 404 error page

some theory

https://knpuniversity.com/screencast/symfony-journey/sub-request-internals

you can write own exception listener , modify behaviour in way.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -