My application now is coupled with some 3d party API service. And i want it to handle some user action in this way: my application do some own logic, and then if API is availiable, user is redirected to some API resource . Let's say it is an image creation. If API is unavailiable, my own logic just goes on, and controller returns some response.

As API interaction doesn't really matter to main logic, and may be soon substituted with own service, i want it to be decoupled with Event Dispatcher. The main problem is redirect. If some API action is successful i want to create a redirection.

So my question is: What is a propper way to solve this problem, and does Event Dispatcher fit as a decoupling tool?

有帮助吗?

解决方案

EventDispatcher should be fine for this. Add a Response property to your api event. The controller dispatches the event, check the response and, if found, redirects to it. The HttpKernel request handler follows the same sort of logic.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top