你可以直接调用插件
public function someAction()
{
// The action in the controller you want the plugin to run
$p = new Application_Plugin_Something();
$p->doSomething();
}
或引导其注册,并有插件检查,看看是执行它
class Application_Plugin_Example extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ($module != 'default' && $controller != 'TheController' && $action != 'TheAction') {
return;
}
// plugin code here...
}
}
// in bootstrap
Zend_Controller_Front::getInstance()
->registerPlugin(
new Application_Plugin_Example()
);
在插件代码,只需更换“默认”用正确的模块,“TheController”和“TheAction”用你希望插件运行的控制器和动作。
某些代码可能对您有所帮助,并描述您正在尝试完成的任务。 – Zoot 2011-12-18 23:43:33