开发者

Zend Framework :: ignoring predispatch for particular action

I am a newbie to Zend framework, I want to know how can we restrict the call to predispatch() function in my controller fo开发者_如何转开发r any particular action.

-DevD


In your controller try

public function preDispatch()
{
    if($this->getRequest()->getActionName() === 'actionName') {
        return; // ignoring preDispatch
    }
    // run preDispatch code when not actionName
}

The preDispatch method is called before any controller Actions are called in the MVC Request Lifecyle. Thus, you cannot disable preDispatch from an individual action.

You can create a property inside your controller or a variable in the preDispatch method where you put in the action names (without the Action suffix) you want preDispatch to return from without doing anything. In the example code above, you wouldn't test against one action name but against the list of action names, probably with in_array.

See http://devzone.zend.com/article/11978-Zend-Framework-MVC-Request-Lifecycle

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜