controller------forward——————解析!

本文详细解析了Magento框架中控制器的_forward方法实现细节,包括如何设置请求参数、控制器名称及模块名称等,并介绍了_initForward方法如何收集_forward调用前后的属性变更。

1

$this->_forward('edit');

2

protected function _forward($action, $controller = null, $module = null, array $params = null)

{

$this->_getSession()->setIsUrlNotice($this->getFlag('', self::FLAG_IS_URLS_CHECKED));

return parent::_forward($action, $controller, $module, $params);

}

3

protected function _forward($action, $controller = null, $module = null, array $params = null)

{

$request = $this->getRequest();

$request->initForward();

if (!is_null($params)) {

$request->setParams($params);

}

if (!is_null($controller)) {

$request->setControllerName($controller);

// Module should only be reset if controller has been specified

if (!is_null($module)) {

$request->setModuleName($module);

}

}

$request->setActionName($action)

->setDispatched(false);

}

4

/**

* Collect properties changed by _forward in protected storage

* before _forward was called first time.

*

* @return Mage_Core_Controller_Varien_Action

*/

public function initForward()

{

if (empty($this->_beforeForwardInfo)) {

$this->_beforeForwardInfo = array(

'params' => $this->getParams(),

'action_name' => $this->getActionName(),

'controller_name' => $this->getControllerName(),

'module_name' => $this->getModuleName()

);

}

return $this;

}

5

/**

* Set flag indicating whether or not request has been dispatched

*

* @param boolean $flag

* @return Zend_Controller_Request_Abstract

*/

public function setDispatched($flag = true)

{

$this->_dispatched = $flag ? true : false;

return $this;

}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值