1

我正在使用 Zend Framework 并提出将请求转发到同一控制器中的另一个操作的情况。

我将请求从create转发到save。我想要做的是检查(从saveAction)请求是转发还是直接请求(不使用任何额外的变量或参数)

init()每次转发都会触发两次功能(一次用于创建,一次用于保存),最好也检查一下init()

class Cms_UserController extends Zend_Controller_Action {

    public function init() {
        parent::init();

        // some code here
    }

    public function createAction() {

        if (!$this->getRequest()->isPost()) {
            // forwarding to cms/user/save
            return $this->_forward('save');
        }

        // do some stuff for POST request
    }

    public function saveAction() {
        // I want to check whether the request is
        // forwarded from 'createAction' or from any action
        // or a direct request to cms/user/save
    }

}
4

1 回答 1

3

希望对你有帮助:

public function lastAction(){
    $request=$this->getRequest()->getParams();
    $request['action']; //you can get corresponding actions here
}
public function testAction(){
    return $this->_forward('last');
}
于 2012-11-28T12:42:39.627 回答