Yaf_Controller_Abstract is the core part of Yaf's MVC system. MVC refers to Model-View-Controller, which is a design pattern used to separate application logic and presentation logic. Each user-defined controller should inherit Yaf_Controller_Abstract. Yaf_Controller_Abstract is the core part of Yaf's MVC system. MVC refers to Model-View-Controller, which is a design pattern used to separate application logic and presentation logic. Each user-defined controller should inherit Yaf_Controller_Abstract.
You will find that the _ construct method cannot be defined in your own controller. Therefore, Yaf_Controller_Abstract provides a magic method Yaf_Controller_Abstract: init (). If you have defined an init () method in your own controller, it will be called when your controller is instantiated.
Yaf_Action_Abstract is the C action in MVC. Generally, the action is defined in the derived class of Yaf_Controller_Abstract. However, sometimes, to make the code clear, some large controllers are separated, yaf_Action_Abstract can be defined separately. The Yaf_Action_Abstract system is scalable. you can inherit the existing classes to implement this abstract class and add your own application logic.
In addition, Yaf_Action_Abstract inherits from Yaf_Controller_Abstract, which is also one of the reasons for putting these two built-in classes together for learning.
[Php] view plaincopyabstract Yaf_Action_Abstract extends Yaf_Action_Controller {public abstract void execute (void);} category class abstract [php] view plaincopyabstract Yaf_Controller_Abstract {/* attribute */public $ actions; protected $ _ module; protected $ _ name; protected $ _ request; protected $ _ response; protected $ _ invoke_args; protected $ _ view; /* method */final private void _ clone (void) final private _ construct (void) protected bool display (string $ tpl [, array $ parameters]) public void forward (string $ module [, string $ controller [, string $ action [, array $ paramters]) public void getInvokeArg (string $ name) public void getInvokeArgs (void) public string getModuleName (void) public Yaf_Request_Abstract getRequest (void) public Yaf_Response_Abstract getResponse (void) public Yaf_View_Interface getView (void) public void getViewpath (void) public void init) public void initView ([array $ options]) public void redirect (string $ url) protected string render (string $ tpl [, array $ parameters]) public void setViewpath (string $ view_directory)} Yaf_Controller_Abstract member method list Yaf_Controller_Abstract ::__ clone-methods cannot be cloned Yaf_Controller_Abstract ::__ construct-example constructor principal :: display-The display purpose Yaf_Controller_Abstract: forward-The forward purpose Yaf_Controller_Abstract: getInvokeArg-The getInvokeArg purpose failed: getInvokeArgs-The getInvokeArgs purpose failed :: getModuleName-get The module name of The current controller: getRequest-The getRequest purpose attributes: getResponse-The getResponse purpose Yaf_Controller_Abstract: getView-get The current view engine Yaf_Controller_Abstract :: getViewpath-The getViewpath purpose attributes: init-controller initialization attributes: initView-The initView purpose attributes: redirect-The redirect purpose Yaf_Controller_Abstract: render-rendering view template Yaf_Controller_Abstract :: setViewpath-The setViewpath purpose for The Controller, The real execution body is an Action defined in The Controller, of course, these actions can also be defined outside the Controller (specified in member $ actions) [php] view plaincopy
"Actions/Dummy_action.php",);/* action method may have arguments */public indexAction ($ name, $ id) {assert ($ name = $ this-> getRequest () -> getParam ("name"); assert ($ id = $ this-> _ request-> getParam ("id") ;}}?> File actions/Dummy_action.php is an action Class [php] view plaincopy
Different from the general framework, you can define action parameters in Yaf. the values of these parameters come from the same name parameter values in the Request route results. for example, for the following controller