Reputation: 106
If I have a UsersController and want to have an admin Prefix, do I need to have one controlle for all basic user functions, and another UsersController inside /Admin with only admin functions? Am I supposed to have two UsersControllers in my code?
Upvotes: 0
Views: 188
Reputation: 60493
If you want to use CakePHP's prefix functionality, then yes, you'll have two UsersController
classes, that's how it's supposed to be. It's not a problem as prefixes do map to namespaces, so the controllers will live in different namespaces, one in App\Controller
and one in App\Controller\Admin
.
If you bake the controllers they'll automatically land in the right place:
bin/cake bake controller Users
bin/cake bake controller Users --prefix Admin
To share common functionality between both controllers, look into using components.
Upvotes: 1