php - action without a view. Need a module? -
i want execute action doesnt need view. in example "logout" function, ajax call (for example, need number back).
should add module? well, i'd rather "flat" script action redirect index page, when done. , in case, put flat script?
yes, still want create module (controller) this.
for number of reasons: - should want change behaviour, it's in code. - logout action want manipulate current (sfuser
) user, instance want fire symfony stack, why not create controller. - it's considered 'bad practice', or 'counter-mvc' if start creating kinds of small files small actions.
and how hard create new module? ./symfony generate:module frontend user
.
if don't have view can forward/redirect request. (in action: $this->redirect('homepage');
).
or, ajax-actions, can return required data:
if ($request->isxmlhttprequest()) { // set correct header return $this->rendertext(json_encode($data)); }
Comments
Post a Comment