Yaf_Dispatcher::autoRender

(Yaf >=1.0.0)

Yaf_Dispatcher::autoRender開(kāi)啟/關(guān)閉自動(dòng)渲染功能

說(shuō)明

public Yaf_Dispatcher::autoRender(bool $flag): Yaf_Dispatcher

在開(kāi)啟的情況下(Yaf默認(rèn)開(kāi)啟),action執(zhí)行完成以后,Yaf_Dispatcher 會(huì)自動(dòng)調(diào)用view引擎去渲染該action對(duì)應(yīng)的視圖模板。 你也可以通過(guò)調(diào)用這個(gè)函數(shù)并將 flag 參數(shù)的值設(shè)為TRUE來(lái)人工干預(yù)它。

注意:

你可以在一個(gè)action中僅僅返回FALSE來(lái)阻止當(dāng)前action對(duì)應(yīng)視圖的自動(dòng)渲染

參數(shù)

flag

bool

返回值

范例

示例 #1 Yaf_Dispatcher::autoRender()example

<?php
class IndexController extends Yaf_Controller_Abstract {
     
/* init method will be called as soon as a controller is initialized */ 
     
public function init() {
         if (
$this->getRequest()->isXmlHttpRequest()) {
             
//do not call render for ajax request
             //we will outpu a json string
             
Yaf_Dispatcher::getInstance()->autoRender(FALSE);
         }
     } 

}
?>

以上例程的輸出類似于: