男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

The Yaf_Controller_Abstract class

(Yaf >=1.0.0)

簡(jiǎn)介

Yaf_Controller_Abstract 是Yaf的MVC體系的核心部分。 MVC是指Model-View-Controller, 是一個(gè)用于分離應用邏輯和表現邏輯的設計模式。

每個(gè)用戶(hù)自定義controller都應當繼承Yaf_Controller_Abstract。

你會(huì )發(fā)現在你自己的controller中無(wú)法定義__construct方法。因此,Yaf_Controller_Abstract 提供了一個(gè)魔術(shù)方法Yaf_Controller_Abstract::init()。

如果在你自己的controller里面已經(jīng)定義了一個(gè)init()方法,當你的controller被實(shí)例化的時(shí)候,它將被調用。

Action可能需要參數,當一個(gè)請求來(lái)到的時(shí)候,在路由中如果請求的參數有相同名稱(chēng)的變量(例如:Yaf_Request_Abstract::getParam()), Yaf將把他們傳遞給action方法(see Yaf_Action_Abstract::execute())。

類(lèi)摘要

abstract class Yaf_Controller_Abstract {
/* 屬性 */
public $actions;
protected $_module;
protected $_name;
protected $_request;
protected $_response;
protected $_invoke_args;
protected $_view;
/* 方法 */
final private __construct()
protected display(string $tpl, array $parameters = ?): bool
public forward(
    string $module,
    string $controller = ?,
    string $action = ?,
    array $paramters = ?
): void
public getInvokeArg(string $name): void
public getInvokeArgs(): void
public getModuleName(): string
public getName(): string
public getViewpath(): void
public init(): void
public initView(array $options = ?): void
public redirect(string $url): void
protected render(string $tpl, array $parameters = ?): string
public setViewpath(string $view_directory): void
}

屬性

actions

你也可以通過(guò)使用這個(gè)值和 Yaf_Action_Abstract 在一個(gè)單獨的PHP腳本中定義action函數。

示例 #1 在一個(gè)獨立的文件中定義action

<?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) {
       
assert($name == $this->getRequest()->getParam("name"));
       
assert($id   == $this->_request->getParam("id"));
    }
}
?>

示例 #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

模塊名

_name

_request

當前的請求實(shí)例

_response

_invoke_args

_view

視圖引擎

目錄

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站