(Yaf >=1.0.0)
Yaf_Controller_Abstract::forward — Foward to another action
$action
[, array $paramters
] ) : void$controller
, string $action
[, array $paramters
] ) : void$module
, string $controller
, string $action
[, array $paramters
] ) : voidforward current execution process to other action.
Nota:
this method doesn't switch to the destination action immediately, it will take place after current flow finish.
moduledestination module name, if NULL was given, then default module name is assumed
controllerdestination controller name
actiondestination action name
paramterscalling arguments
Exemplo #1 Yaf_Controller_Abstract::forward()example
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction(){
$logined = $_SESSION["login"];
if (!$logined) {
$this->forward("login", array("from" => "Index")); // forward to login action
return FALSE; // this is important, this finish current working flow
// and tell the Yaf do not doing auto-render
}
// other processes
}
public function loginAction() {
echo "login, redirected from ", $this->_request->getParam("from") , " action";
}
}
?>
O exemplo acima irá imprimir algo similar à:
login, redirected from Index action
return FALSE on failure