I have had the module directory structure in my application folder. I have put the specific module related options in my application.ini (multilanguage support):
[text]resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = On
resources.router.routes.defaultmodule.type = Zend_Controller_Router_Route_Module
resources.router.routes.defaultmodule.abstract = On
resources.router.routes.defaultmodule.defaults.module = "default"
resources.router.routes.language.type = Zend_Controller_Router_Route
resources.router.routes.language.route = ":language"
resources.router.routes.language.reqs.language = "^(bg|en)$"
resources.router.routes.language.defaults.language = "bg"
resources.router.routes.default.type = Zend_Controller_Router_Route_Chain
resources.router.routes.default.chain = "language, defaultmodule"[/text]
I have put the Bootstrap.php (extends Zend_Application_Module_Bootstrap) files in each of my modules root directories.
I've read that even I had made this, *every* single module Bootstrap file will be executed after the application Bootstrap (very annoying).
Question: how to distinguish in my module Bootstrap files the action controller of which module is about to be executed, so I can take different actions in them?
[Zend] Modules and module specific Bootstrap
Moderator: General Moderators
[Zend] Modules and module specific Bootstrap
There are 10 types of people in this world, those who understand binary and those who don't
Re: [Zend] Modules and module specific Bootstrap
A dirty solution...
and
There is a protected property in the Dispatcher, but no getter ... 
[text]object(Zend_Controller_Dispatcher_Standard)[18]
protected '_curDirectory' => null
protected '_curModule' => string 'admin' (length=7)[/text]
Code: Select all
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initModuleDiscovery()
{
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
$front->currentModule = array_pop(explode('/', $front->getModuleDirectory()));
}Code: Select all
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initApplication()
{
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
echo $front->currentModule;
}
}[text]object(Zend_Controller_Dispatcher_Standard)[18]
protected '_curDirectory' => null
protected '_curModule' => string 'admin' (length=7)[/text]
There are 10 types of people in this world, those who understand binary and those who don't
Re: [Zend] Modules and module specific Bootstrap
I think what I did was wrong in general. Maybe I've been misled by users' comments about using Zend Modules for having multiple web sites /parts(e.g. the Admin backend panel and web site frontend). In my understanding, Zend Modules are used for reusable parts (modules) of a single application and not for defining/implementing multiple applications. The "default" module (i.e. the main application) should reside in the root directory, while the reusable parts are put into the "modules" (e.g.) directory. So, having every module Bootstrap executed after the "main" application Bootstrap is a good thing and it's a must.
That's the way I see it.
That's the way I see it.
There are 10 types of people in this world, those who understand binary and those who don't
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: [Zend] Modules and module specific Bootstrap
I would disagree with your your last comments. Modules are a perfect candadate for standalone applications, although more often then not modules will share common library functionality so it doesn't necessarily end up that way.
I've also sent you a PM.
I've also sent you a PM.
Re: [Zend] Modules and module specific Bootstrap
I agree and disagree - every module, including the default module should be a good candidate for a standalone application. I think, the way Zaend wanted it, was to have these applications as reusable parts - that's why the default module Bootstrap is executed first (so it can set up the enviroment for other modules e.g.)
http://imgur.com/FbPFQ.png
http://imgur.com/FbPFQ.png
There are 10 types of people in this world, those who understand binary and those who don't