Action_Abstract
abstract class Action_Abstract extends Controller_Abstract (View source)
A action can be defined in a separate file in Yaf(see \Yaf\Controller_Abstract). that is a action method can also be a \Yaf\Action_Abstract class.
Since there should be a entry point which can be called by Yaf (as of PHP 5.3, there is a new magic method __invoke, but Yaf is not only works with PHP 5.3+, Yaf choose another magic method execute), you must implement the abstract method \Yaf\Action_Abstract::execute() in your custom action class.
Properties
array | $actions | from Controller_Abstract | |
protected string | $_module | from Controller_Abstract | |
protected string | $_name | from Controller_Abstract | |
protected Request_Abstract | $_request | from Controller_Abstract | |
protected Response_Abstract | $_response | from Controller_Abstract | |
protected array | $_invoke_args | from Controller_Abstract | |
protected View_Interface | $_view | from Controller_Abstract | |
protected Controller_Abstract | $_controller |
Methods
forward current execution process to other action.
Note:
this method doesn't switch to the destination action immediately, it will take place after current flow finish.
Notice, there are 3 available method signatures:
\Yaf\Controller_Abstract::forward ( string $module , string $controller , string $action [, array $parameters ] )
\Yaf\Controller_Abstract::forward ( string $controller , string $action [, array $parameters ] )
\Yaf\Controller_Abstract::forward ( string $action [, array $parameters ] )
\Yaf\Controller_Abstract::__construct() is final, which means users can not override it. but users can define \Yaf\Controller_Abstract::init(), which will be called after controller object is instantiated.
\Yaf\Controller_Abstract::__construct() is final, which means it can not be overridden. You may want to see \Yaf\Controller_Abstract::init() instead.
user should always define this method for a action, this is the entry point of an action. \Yaf\Action_Abstract::execute() may have arguments.
Note:
The value retrieved from the request is not safe. you should do some filtering work before you use it.
retrieve current controller object.
Details
protected string
render(string $tpl, array $parameters = null)
No description
protected bool
display(string $tpl, array $parameters = null)
No description
Request_Abstract
getRequest()
retrieve current request object
Response_Abstract
getResponse()
retrieve current response object
string
getModuleName()
get the controller's module name
View_Interface
getView()
retrieve view engine
Response_Abstract
initView(array $options = null)
deprecated
deprecated
No description
bool
setViewpath(string $view_directory)
No description
string
getViewpath()
No description
bool
forward(string $module, string $controller = null, string $action = null, array $parameters = null)
forward current execution process to other action.
Note:
this method doesn't switch to the destination action immediately, it will take place after current flow finish.
Notice, there are 3 available method signatures:
\Yaf\Controller_Abstract::forward ( string $module , string $controller , string $action [, array $parameters ] )
\Yaf\Controller_Abstract::forward ( string $controller , string $action [, array $parameters ] )
\Yaf\Controller_Abstract::forward ( string $action [, array $parameters ] )
bool
redirect(string $url)
redirect to a URL by sending a 302 header
array
getInvokeArgs()
No description
mixed|null
getInvokeArg(string $name)
No description
init()
\Yaf\Controller_Abstract::__construct() is final, which means users can not override it. but users can define \Yaf\Controller_Abstract::init(), which will be called after controller object is instantiated.
final
__construct(Request_Abstract $request, Response_Abstract $response, View_Interface $view, array $invokeArgs = null)
\Yaf\Controller_Abstract::__construct() is final, which means it can not be overridden. You may want to see \Yaf\Controller_Abstract::init() instead.
abstract mixed
execute()
user should always define this method for a action, this is the entry point of an action. \Yaf\Action_Abstract::execute() may have arguments.
Note:
The value retrieved from the request is not safe. you should do some filtering work before you use it.
Controller_Abstract
getController()
retrieve current controller object.