Zend Unset Action helper from controller action
Zend framework talk.I'm initializing in my bootstrap class My_Action_Helper_Custom (extendin开发者_C百科g Zend_Controller_Action_Helper_Abstract) to make it available to all of my controllers.
Could I just disable it for a specific action where I dont need it?
thanks
Luca
Are you referring to disabling the preDispatch()
or postDispatch()
hooks for a particular controller action?
If so, I'd add some form of blacklist property to the helper, for example
/**
* @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
}
精彩评论