2009年11月3日星期二

[fw-mvc] How to use common project prefix in modules?

Hi, guys!
I've got the following application structure:
.
|-- configs
|-- controllers     // common controllers
|-- forms
|-- helpers
|-- layouts
|   `-- scripts
|-- models         // common models
|-- modules      
|   |-- adm         // admin module
|   |   |-- controllers
|   |   |-- models
|   |   `-- views
|   `-- request    // some other module
|       |-- controllers
|       `-- views
|-- services
`-- views
    |-- helpers
    `-- scripts
        |-- error
        `-- index


So I've managed common prefix to all project, say, MyProject in bootstrap file:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
   
    protected function _initAutoload() {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'MyProject_',
            'basePath'  => dirname(__FILE__),
        ));

        $autoloader->addResourceType('helper', 'helpers', 'Helper');

        return $autoloader;
    }
}

So, common models have this prefix, i.e. model user is named as MyProject_Model_User and it's ok. But all controllers don't have this prefix, i.e. common index controller is just IndexController, so I'd like to name it MyProject_IndexController and controllers in admin module should be MyProject_Adm_IndexController for example.
How to do this?


--
Regards,
Shein Alexey

没有评论: