Yaf_Controller_Abstract
abstract class Yaf_Controller_Abstract (View source)
Yaf_Controller_Abstract is the heart of Yaf's system. MVC stands for Model-View-Controller and is a design pattern targeted at separating application logic from display logic.
Every custom controller shall inherit Yaf_Controller_Abstract.
You will find that you can not define __construct function for your custom controller, thus, Yaf_Controller_Abstract provides a magic method: Yaf_Controller_Abstract::init().
If you have defined a init() method in your custom controller, it will be called as long as the controller was instantiated.
Action may have arguments, when a request coming, if there are the same name variable in the request parameters(see Yaf_Request_Abstract::getParam()) after routed, Yaf will pass them to the action method (see Yaf_Action_Abstract::execute()).
Note:
These arguments are directly fetched without filtering, it should be carefully processed before use them.
Properties
array | $actions | ||
protected string | $_module | ||
protected string | $_name | ||
protected Yaf_Request_Abstract | $_request | ||
protected Yaf_Response_Abstract | $_response | ||
protected array | $_invoke_args | ||
protected Yaf_View_Interface | $_view |
Methods
No description
No description
retrieve current request object
retrieve current response object
get the controller's module name
retrieve view engine
No description
No description
No description
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 ] )
redirect to a URL by sending a 302 header
No description
No description
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.
Details
protected string|null|bool
render(string $tpl, array|null $parameters = null)
No description
protected bool
display(string $tpl, array|null $parameters = null)
No description
Yaf_Request_Abstract
getRequest()
retrieve current request object
Yaf_Response_Abstract
getResponse()
retrieve current response object
string
getModuleName()
get the controller's module name
Yaf_View_Interface
getView()
retrieve view engine
string|null
getName()
No description
Yaf_Response_Abstract
initView(array|null $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|null $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
getInvokeArg(string $name)
No description
void
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.
__construct(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response, Yaf_View_Interface $view, array|null $args = null)
Yaf_Controller_Abstract::__construct() is final, which means it can not be overridden. You may want to see Yaf_Controller_Abstract::init() instead.