Zend框架对话。我正在引导程序类my_Action_Helper_Custom中进行初始化(扩展Zend_Controller_Action_Help.Abstract),使其可用于我的所有控制器。
我可以在不需要的特定操作中禁用它吗
感谢
Luca
您指的是为特定控制器操作禁用preDispatch()
或postDispatch()
挂钩吗?
如果是这样的话,我会向助手添加某种形式的黑名单属性,例如
/**
* @var array
*/
private $blacklistActions = array();
public function addBlacklistAction($action)
{
// store actions in string form
// eg, module.controller.action
$this->blacklistActions[] = $action;
}
public function preDispatch()
{
$request = $this->getRequest();
$action = sprintf('%s.%s.%s',
$request->getModuleName(),
$request->getControllerName(),
$request->getActionName());
if (in_array($action, $this->blacklistActions)) {
return;
}
// the rest
}