I have two separate CakePHP 3.1 apps that each use the same database, but display the information in very different ways. To reduce code duplication, I'm extracting most of the models into a plugin. The controllers differ wildly from each other, so I am not including any of them in the plugin at the moment. What is the proper way to specify that the primary model for a controller resides in a plugin?
In previous versions of CakePHP, the answer would have been to use the $uses
property of the controller, but as far as I can tell this is no longer an option. As best I can tell, the only way to make the plugin model accessible from all actions is to do a loadModel
in the controller's initialize method. Is that the optimal way to handle this situation?