M
M
magary42017-03-16 18:03:47
symfony
magary4, 2017-03-16 18:03:47

How to make controllers with flexible Response?

very often different results are needed from project to project - one project needs render, another redirect in the third JsonResponse, and so on,
you have to redefine controllers in each project, and only the last couple of lines of action functions,
what do you advise?
Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Netesin, 2017-03-16
@knetesin

change the response depending on some parameter? (get, post is not important and add a switch case construction on it)
or, yes, you can use events to modify the response object for your purposes in the project - but in this case you will have to write a handler, from the obvious pluses - it will allow you to transfer some common part to vendors and modify, as needed, only the event handler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question