Duplicate controller names from different plugins

I have a question about the file upload system from Cakephp2.3.

I have two plugins - call them "Contacts" and "Managers" loaded like this:

CakePlugin::load('Contacts');
CakePlugin::load('Managers');

      

Each one has a controller called "DashboardController.php" with an index () action.

When I try to access the dashboard page for "Contacts", sometimes I see the following error:

Error: Class "ManagersAppController" not found

      

although the url looks like this:

http://mysite.com/contacts/dashboard

      

I read that Cakephp2.3 does not support namespaces and this can happen because I have two php classes (DashboardController.php) with the same name. At the same time, I know that Cake has to display the plugin name first so that it can handle duplicate filenames.

Do you have any idea why I am seeing this random error?

Thank you for your help.

+3


source to share


1 answer


I just found an answer from the guys developed by CakePHP. Indeed, you cannot have two controllers or models with the same name, even if they are located in different plugins.

This only happens in CakePHP2.x and I am quoting:

This is a known limitation of Cake2.x and the lazy loading approach using :: uses ()



You can see my question and their answer here: http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3558-loading-file-from-a-different-plugin

The solution is to rename the controllers / models with conflicting names and / or name all controllers and models from the plugin using the plugin name (for example, DashboardController.php will become ContactsDashboardController.php)

+4


source







All Articles