开发者

what plugin execute at first on zend framework?

开发者 https://www.devze.com 2022-12-24 23:22 出处:网络
i registered 2 plugin in my project on zend framework the first one in application.ini this is for change layout

i registered 2 plugin in my project on zend framework the first one in application.ini this is for change layout resources.frontController.plugins.LayoutSet="App_Plugins_LayoutSet" and second in the registred in the bootstrap

 $fc= Zend_Controller_Front::getInstance();
          $fc->registerPlugin(new App_Plugins_AccessCheck($this->_acl));

2 plugin work fine , i want to know what plugin execute at first , can we change prior's exec开发者_如何学Goute for these plugin?


Plugins are triggered in the same order they are registered. You can override this behavior by passing a "stack index" when registering Plugins.

The OO way:

$front->registerPlugin(new FooPlugin(), 1);   // will trigger early
$front->registerPlugin(new BarPlugin(), 100); // will trigger late

The application.ini way:

resources.frontController.plugins.foo.class = "FooPlugin"
resources.frontController.plugins.foo.stackIndex = 1      // will trigger early
resources.frontController.plugins.bar.class = "BarPlugin"
resources.frontController.plugins.bar.stackIndex = 100    // will trigger late

Source: Zend Controller Plugins in ZF


The above answer is only partially correct. Yes, the plugins are triggered in the same order they are registered in but it also matters which event method a plugin uses. For instance, preDispatch() will be triggered before postDispatch() and so on.

See http://framework.zend.com/manual/en/zend.controller.plugins.html

0

精彩评论

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

关注公众号