How do I determine routing information when loading frontcontroller plugins?
I have recently added an admin module to my application. This application has separate authentication from the main site(the admin tools may be used later across different sites for different applications and the admin users are stored in a separate table), and this is causing issues. Because of the the singleton nature of Zend_Auth, I'm overwriting my Zend_Auth instance at critical times, and blowing up my application. So...
I'd like to try to determine which module is being requested in the bootstrap and load only the appropriate front controller plugin. Is there a way to determine which module is being requested at this point of execution, or is there a better solution? How? Below is the method in the bootstrap to initialize the front controller plugins.
protected function _initFrontControllerPluginWithOptions() { $开发者_StackOverflow社区this->bootstrap(array('frontController', 'ResourceLoader', 'session', ));
//get site specifics
$sessionInfo = $this->getOption("resources");
if ($namespace = $sessionInfo['session']['name']) {
$data = array("cookieName" => $namespace);
} else {
throw new Exception("Authplugin can't find session namespace");
}
$frontController = $this->getResource("frontController");
//register plugins
$frontController->registerPlugin(new GS_Admin_Plugin_Auth_Admin($data));
$frontController->registerPlugin(new GS_Model_Plugin_Auth_User($data));
}
This doesn't answer your question directly but one way I've handled this situation in the past is to have multiple entry points for the application, i.e. 2 or more index.php files. In each different index.php you can set a flag with a define that states where the program is entering from. Based on that, you can load different controller plugins.
An example set up for your public folder might be:
/index.php
/admin/index.php
From both these you will still call the same Bootstrap class.
精彩评论