当前位置: 首页 > 文档资料 > Yaf 用户手册 >

11.11. The Yaf_View_Interface class

优质
小牛编辑
116浏览
2023-12-01

简介

Yaf_View_Interface是为了提供可扩展的, 可自定的视图引擎而设立的视图引擎接口, 它定义了用在Yaf上的视图引擎需要实现的方法和功能.

在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用Yaf\View_Interface

 
  interface 
  Yaf_View_Interface
{
public string render( string  $view_path ,
  array  $tpl_vars = NULL );
public boolean display( string  $view_path ,
  array  $tpl_vars = NULL );
public boolean assign( mixed  $name ,
 mixed  $value = NULL );
public boolean setScriptPath( string  $view_directory );
public string getScriptPath( void  );
}

The Yaf_View_Simple class

简介

Yaf_View_Simple是Yaf自带的视图引擎, 它追求性能, 所以并没有提供类似Smarty那样的多样功能, 和复杂的语法.

对于Yaf_View_Simple的视图模板, 就是普通的PHP脚本, 对于通过Yaf_View_Interface::assgin的模板变量, 可在视图模板中直接通过变量名使用.

在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用 Yaf\View_Simple

 
  Yaf_View_Simple
extends
Yaf_View_Interface
{
  
  protected 
  array 
 _tpl_vars

   ;
  
  protected 
  string 
 _script_path

   ;
public string 
 render
( string  $view_path ,
 array  $tpl_vars = NULL );
public boolean 
 display
( string  $view_path ,
 array  $tpl_vars = NULL );
public boolean 
 setScriptPath
( string  $view_directory );
public string 
 getScriptPath
( void  );
public boolean 
 assign
  ( string  $name ,
  mixed  $value );
public boolean 
 __set
  ( string  $name ,
 mixed  $value = NULL );
public mixed 
 __get
  ( string  $name );
}
属性说明
_tpl_vars

所有通过Yaf_View_Simple::assign分配的变量, 都保存在此属性中

_script_path

当前视图引擎的模板文件基目录