Hey guys, I'm working on a module based zend framework application, which uses the following structure:
application
modules
backend
controllers, models etc...
frontend
controllers, models etc.
Hence all frontend model开发者_StackOverflow社区s would be initated by called new Frontend_Model_*()... But I dont like this solution, cause I want the models in the backend, too.
For the controller side, I used the following option within my application.ini:
resources.frontController.params.prefixDefaultModule = false
Now my Frontend_IndexController is simply called Index_Controller. Is there a simple way to do the same for models, forms, etc?
Which means a call like "new Model_*()" should lead directly to the frontend module, which is the default module. To call a backend model I had to use "new Backend_Model_*()"...
Thanks in advance!!!
I managed to get this thing working. In order to use autoloading in the case mentioned above, I had to do the following within my frontend bootstrap file:
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => dirname(__FILE__),
));
}
This sets the autoloading prefix to nothing, so one can initiate a frontend model through "new Model_*()". A backend model can still be initiated through "new Backend_Model_*()"
Note: The frontend bootstrap file is the only one, which should be touched in order to get this thing running!
Hope that helps somebody!
精彩评论