Redirecting in service - symfony2

前端 未结 5 506
南方客
南方客 2021-01-17 22:03

May I perform redirection to another controller within service?

I have implemented a service based on example provided by @Artamiel.

My function code which i

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 22:44

    From an architecture point of view one should not create a RedirectResponse in a service. One way could be to throw an exception in the service, which is caught in the controller's action where you can easily create a RedirectResponse.

    An example can be found here: Redirect from a Service in Symfony2

提交回复
热议问题