Yaf_Controller_Abstract::forward
(Yaf >=1.0.0)
Yaf_Controller_Abstract::forward — 转发到另一个动作
说明
public Yaf_Controller_Abstract::forward(string
$controller
, string $action
, array $paramters
= ?): boolpublic Yaf_Controller_Abstract::forward(
string
string
string
array
): bool
string
$module
,string
$controller
,string
$action
,array
$paramters
= ?): bool
转发当前处理过程到其他动作。
注意:
此方法不会立即切换到目标操作,而是会在当前流程结束后发生。
参数
module
-
目标模块名称,如果是 NULL,则采用默认模块名
controller
-
目标控制器名称
action
-
目标动作名称
paramters
-
调用参数
示例
示例 #1 Yaf_Controller_Abstract::forward() 示例
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction(){
$logined = $_SESSION["login"];
if (!$logined) {
$this->forward("login", array("from" => "Index")); // 转发到 login 动作
return FALSE; // 这非常重要,这会结束当前工作流
// 然后告诉 Yaf 不要自动渲染
}
// other processes
}
public function loginAction() {
echo "login, redirected from ", $this->_request->getParam("from") , " action";
}
}
?>
以上示例的输出类似于:
login, redirected from Index action
参见
- Yaf_Request_Abstrace::getParam()
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/yaf-controller-abstract.forward.php