开发者

Zend MVC load config based on parameter in Url. Where is the right point dispatch/router/controller?

开发者 https://www.devze.com 2023-03-22 18:16 出处:网络
I\'m defining a partner through a route based on the url e.g. my.domain.com/:partner/:controller/:action

I'm defining a partner through a route based on the url e.g.

my.domain.com/:partner/:controller/:action

Now I want load the c开发者_开发问答onfig file, databases for the partner before the front controller is called.

  • Where do I locate this code?
  • How do I get/set the variables/db, that they are later available in the controller?

I know I could do this through a controller helper but I guess this is not the best point to do it?


Yes, a controller plugin is the way I'd do it:

class MyPlugin extends Zend_Controller_Plugin_Abstract
{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        switch($request->getParam('partner')) {
            //... do something based on the possibility
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消