How to get request type (master/sub) in Symfony2 controller?

前端 未结 3 872
梦如初夏
梦如初夏 2021-02-19 17:23

Is there possible get request type in controller? How?

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 18:01

    To detect if the request is a master or not requires the use of the RequestStack, which should be injected into your controller. The request stack has 3 useful methods

    getCurrentRequest();
    getMasterRequest();
    getParentRequest();
    

    The getParentRequest() will always return null if the current request is the master.

提交回复
热议问题