Yaf_Controller_Abstract::forward
(Yaf >=1.0.0)
Forward the current request to another action
Description
Forward the current request to another action. The target is determined from the number and types of the arguments:
actiononly: forward to another action of the current controller.controllerandaction: forward to another controller.module,controllerandaction: forward to another module.- The optional
parametersarray carries invocation arguments retrievable withYaf_Request_Abstract::getParam.
This method does not switch to the destination action immediately; the switch takes place after the current flow finishes. To hand over control right away, return from the current action method (returning false also tells Yaf not to auto-render the current view).
Parameters
moduleThe destination module name. If the current module is given, it is used as is.
controllerThe destination controller name.
actionThe destination action name.
parametersInvocation arguments for the destination action, retrievable with
Yaf_Request_Abstract::getParam.
Return Values
Returns true on success, or false / null on failure.
Examples
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 the login action
return false; // this is important, it ends the current flow
// and tells Yaf not to auto-render
}
// other processes
}
public function loginAction() {
echo "login, redirected from ", $this->_request->getParam("from") , " action";
}
}
?>The above example will output something similar to:
login, redirected from Index actionSee Also
Yaf_Request_Abstract::getParam