Well right now my site has only a simple URL routing mechanism, in which the router/dispatcher simply interprets the url as domain.com/scriptpath/controller/action/param-1/param-2.../param-n. However, real life can get complicated at times, consider the AdminCP url in which you have a user controller that you can add, search, edit and delete users. The add and search actions are pretty easy to set up, but the edit and delete can be a bit tricky as you always need user id to be supplied to carry out these actions(thus always a parameter userid is required).
What if the userid is not supplied? Well, you may either search for it in the search action, or to be directed to a special manager controller for its outer/master user controller(called UserManager in this case). This user manager either displays an HTML table showing users available in the system with links to edit or delete them(its index action), or delegates to the edit or delete action if these actions and user id are specified. If no id is specified, the manager will always show the default user table. With this, the edit and delete actions actually become actions of UserManager and sub-actions of UserController.
Now you see how it gets complicated, the user controller now have two actions add, search, and a manager/sub-controller with two sub-actions edit, delete. The url patterns get a bit complex, as you can see below:
I want to design the manager as a class using the composition pattern, in which the controller has a manager property. However, the router cannot easily distinguish whether the word 'manage' represents an action or an inner controller, which creates routing problem. In simple scenario, I can make the manage a keyword for the router to search when it conducts regular expression matching. It works if the manager is the only special inner-controller, but can get quite messy when you have lots of such inner controllers.
So what would you do if you were facing this problem? I know HMVC may work, but not sure how to design it. How about other possible ways to get it done?