The Yaf_Controller_Abstract class
(Yaf >=1.0.0)
Introduction
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.
Class synopsis
Properties
- actions
-
You can also define a action method in a separate PHP script by using this property and Yaf_Action_Abstract.
Example #1 define action in a separate file
<?php
class IndexController extends Yaf_Controller_Abstract {
protected $actions = array(
/** now dummyAction is defined in a separate file */
"dummy" => "actions/Dummy_action.php",
);
/* action method may have arguments */
public indexAction($name, $id) {
/* $name and $id are unsafe raw data */
assert($name == $this->getRequest()->getParam("name"));
assert($id == $this->_request->getParam("id"));
}
}
?>Example #2 Dummy_action.php
<?php
class DummyAction extends Yaf_Action_Abstract {
/* a action class shall define this method as the entry point */
public execute() {
}
}
?> - _module
-
module name
- _name
-
controller name
- _request
-
current request object
- _response
-
current response object
- _invoke_args
- _view
-
view engine object
Table of Contents
- Yaf_Controller_Abstract::__clone — Yaf_Controller_Abstract can not be cloned
- Yaf_Controller_Abstract::__construct — Yaf_Controller_Abstract constructor
- Yaf_Controller_Abstract::display — The display purpose
- Yaf_Controller_Abstract::forward — foward to another action
- Yaf_Controller_Abstract::getInvokeArg — The getInvokeArg purpose
- Yaf_Controller_Abstract::getInvokeArgs — The getInvokeArgs purpose
- Yaf_Controller_Abstract::getModuleName — Get module name
- Yaf_Controller_Abstract::getRequest — Retrieve current request object
- Yaf_Controller_Abstract::getResponse — Retrieve current response object
- Yaf_Controller_Abstract::getView — Retrieve the view engine
- Yaf_Controller_Abstract::getViewpath — The getViewpath purpose
- Yaf_Controller_Abstract::init — Controller initializer
- Yaf_Controller_Abstract::initView — The initView purpose
- Yaf_Controller_Abstract::redirect — Redirect to a URL
- Yaf_Controller_Abstract::render — Render view template
- Yaf_Controller_Abstract::setViewpath — The setViewpath purpose
- Введение
- Установка и настройка
- Предопределенные константы
- Примеры
- Application Configuration
- The Yaf_Application class
- The Yaf_Bootstrap_Abstract class
- The Yaf_Dispatcher class
- The Yaf_Config_Abstract class
- The Yaf_Config_Ini class
- The Yaf_Config_Simple class
- The Yaf_Controller_Abstract class
- The Yaf_Action_Abstract class
- The Yaf_View_Interface class
- The Yaf_View_Simple class
- The Yaf_Loader class
- The Yaf_Plugin_Abstract class
- The Yaf_Registry class
- The Yaf_Request_Abstract class
- The Yaf_Request_Http class
- The Yaf_Request_Simple class
- The Yaf_Response_Abstract class
- The Yaf_Route_Interface class
- The Yaf_Route_Map class
- The Yaf_Route_Regex class
- The Yaf_Route_Rewrite class
- The Yaf_Router class
- The Yaf_Route_Simple class
- The Yaf_Route_Static class
- The Yaf_Route_Supervar class
- The Yaf_Session class
- The Yaf_Exception class
- The Yaf_Exception_TypeError class
- The Yaf_Exception_StartupError class
- The Yaf_Exception_DispatchFailed class
- The Yaf_Exception_RouterFailed class
- The Yaf_Exception_LoadFailed class
- The Yaf_Exception_LoadFailed_Module class
- The Yaf_Exception_LoadFailed_Controller class
- The Yaf_Exception_LoadFailed_Action class
- The Yaf_Exception_LoadFailed_View class
Коментарии
404 Not Found