简体   繁体   中英

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() { $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, ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM