Re: Sub action dispatching
Reply #1 –
I don't think having several files is better than an array at the top of one file. I think that's actually messier.
Re: Sub action dispatching
Reply #2 –
Not several files.
The number of files would not change from what it is now. Internal methods will be "detected" based on name pattern instead of the array (action_*), the first code block above.
The "several" (or better additional) files are just for addons, like it is even now, just recognized by naming pattern instead of having to use hooks and add a new entry to the array.
Re: Sub action dispatching
Reply #3 –
Yes I'm talking add ons. Or mods. Basically all the controllers I've written would now have to be several files instead of one right?
Re: Sub action dispatching
Reply #4 –
It depends.
What kind of controllers did you write?
A controller to extend for example BoardIndex.controller.php?
Or a controller to create your own action?
Re: Sub action dispatching
Reply #7 –
Would we still handle pre_dispatch actions which we kind of use as constructors? Guess it could still check if that exits then call it, then if the action exists call it, otherwise action_index?
Some of those actions get complicated as they call can call actions in other controllers with the file-> controller-> action-> in the array, and of course show/not show items and permissions, admin tabs, etc ... I like the idea, just trying to wrap my head around how much would have to be done to implement.
Re: Sub action dispatching
Reply #11 –
I like that you're trying to simplify it, but I think it is going to make it more complex for developers.
What a lot of software does is use a file which defines all of the routes. They also define them in a RESTful way, so you don't have to check in each file.
What if you want to change the route and you have subrouting/forwarding? With named routes, all you need to do is change it at the name.