How to use common project prefix in modules?

2 messages Options
Embed this post
Permalink
conf

How to use common project prefix in modules?

Reply Threaded More More options
Print post
Permalink
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
weierophinney

Re: How to use common project prefix in modules?

Reply Threaded More More options
Print post
Permalink
-- Алексей Шеин <[hidden email]> wrote
(on Wednesday, 04 November 2009, 11:49 AM +0500):
> 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?

You need to configure the front controller/dispatcher.

Add the following key/value pair to your configuration:

    resources.frontcontroller.defaultmodule = "MyProject"
    resources.frontcontroller.controllerdirectory.MyProject = APPLICATION_PATH "/controllers"

and that *should* do it.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/