Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Controller "before" action. #32

Open
emlynwest opened this issue Apr 18, 2017 · 4 comments
Open

Controller "before" action. #32

emlynwest opened this issue Apr 18, 2017 · 4 comments
Milestone

Comments

@emlynwest
Copy link
Contributor

Allow a method to run logic before an action is run, with the ability to skip the action if needed. (I remember this being requested lots in v1)

@emlynwest emlynwest added this to the 2.0.0-beta1 milestone Apr 18, 2017
@sagikazarmark
Copy link

Should this be something that we register as part of the route?

If one action/controller then we could also do something like beforeGet, beforePost, etc (IIRC @WanWizard mentioned something like HTTP-method methods)

@WanWizard
Copy link

That was indeed the direction I was thinking. If you only have one single action, you have a lot more flexibility in the controller, without making it too complex.

@sagikazarmark
Copy link

sagikazarmark commented Apr 18, 2017

To be honest, I generally agree with the one action/controller idea, but there are cases when I would like to put multiple actions in a controller (eg. a few related static pages) and I don't want such limitation (as a user).

@WanWizard
Copy link

If we have multiple base controller classes, and we deal with the actual calling of methods inside the __invoke() of those classes, it should be possible to have both, so the user can choose.

The only thing we have to look at when we get there, is the route-to-controller mapping, because based on the type of system in use, you need to load a different file. But I'd say we tackle that when we get there...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants