Войти через VK Войти через FB Войти через Google Войти через Яндекс
Поиск по сайту
The Yaf_Controller_Abstract class
(Информация о версии неизвестна, возможно, только в SVN)
Введение
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()).
Обзор классов
abstract Yaf_Controller_Abstract {
/* Свойства */
public $Yaf_Controller_Abstract->actions ;
protected $_module ;
protected $_name ;
protected $_request ;
protected $_response ;
protected $_invoke_args ;
protected $_view ;
/* Методы */
final private void Yaf_Controller_Abstract::__clone ( void )
final private Yaf_Controller_Abstract::__construct ( void )
final protected void Yaf_Controller_Abstract::display ( string $tpl [, array $parameters ] )
final public void Yaf_Controller_Abstract::forward ( string $module [, string $controller [, string $action [, array $paramters ]]] )
final public void Yaf_Controller_Abstract::getInvokeArg ( string $name )
final public void Yaf_Controller_Abstract::getInvokeArgs ( void )
final public void Yaf_Controller_Abstract::getModuleName ( void )
final public void Yaf_Controller_Abstract::getRequest ( void )
final public void Yaf_Controller_Abstract::getResponse ( void )
final public void Yaf_Controller_Abstract::getView ( void )
final public void Yaf_Controller_Abstract::getViewpath ( void )
final public void Yaf_Controller_Abstract::initView ([ array $options ] )
final public void Yaf_Controller_Abstract::redirect ( string $url )
final protected void Yaf_Controller_Abstract::render ( string $tpl [, array $parameters ] )
final public void Yaf_Controller_Abstract::setViewpath ( string $view_directory )
}
Свойства
actions -
You can also define a action method in a separate PHP script by using this property and Yaf_Action_Abstract.
Пример #1 define action in a separate file
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) {
assert($name == $this->getRequest()->getParam("name"));
assert($id == $this->_request->getParam("id"));
}
}
Пример #2 Dummy_action.php
class DummyAction extends Yaf_Action_Abstract {
/* a action class shall define this method as the entry point */
public execute() {
}
}
_module -
module name
_name -
_request -
the request object
_response -
_invoke_args -
_view -
view engine object
Содержание
- 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 — The forward purpose
- Yaf_Controller_Abstract::getInvokeArg — The getInvokeArg purpose
- Yaf_Controller_Abstract::getInvokeArgs — The getInvokeArgs purpose
- Yaf_Controller_Abstract::getModuleName — The getModuleName purpose
- Yaf_Controller_Abstract::getRequest — The getRequest purpose
- Yaf_Controller_Abstract::getResponse — The getResponse purpose
- Yaf_Controller_Abstract::getView — The getView purpose
- Yaf_Controller_Abstract::getViewpath — The getViewpath purpose
- Yaf_Controller_Abstract::initView — The initView purpose
- Yaf_Controller_Abstract::redirect — The redirect purpose
- Yaf_Controller_Abstract::render — The render purpose
- Yaf_Controller_Abstract::setViewpath — The setViewpath purpose
Описание класса yaf_controller_abstract, примеры использования класса yaf_controller_abstract.
Смотрите также:
Описание на ru2.php.net
Описание на php.ru