I am currently figuring out a way to the the above.
My current application structure is as follows:
/modules
/ modulename
/controllers
/ProjectController.php
The application has 3 different user roles, each with functionality contained within these modules. I'd like to prevent having multiple actions for each user role in one controller as I think it makes my code less readable and ugly. So, I was thinking about a structure like this:
/modules
/ modulename
/controllers
/ProjectController.php
/EmployeeProjectController.php
/ExecutiveProjectController.php
This should work as follows:
- Projectcontroller.php should be loaded for admin users
- EmployeeProjectController.php should be loaded for employees
- ExecutiveProjectController.php should be loaded for executives
Of course, I could relatively easy a different URL scheme to provide for this for each user role, but I do not want this. I want a uniform URL scheme.
Next step would then be to create routes for each of the controllers to rewrite them to another controller. I'd like to prevent this as well.
I want a way to globally tell the router to prefix controllers with 'Executive' or 'Employee' or whatever, based on the user role.
What would be the best way to this?