11.12. The Yaf_Request_Abstract class
优质
小牛编辑
137浏览
2023-12-01
简介
代表了一个实际请求, 一般的不用自己实例化它, Yaf_Application在run以后会自动根据当前请求实例它
在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用Yaf\Request_Abstract
abstract Yaf_Request_Abstract {属性说明protected string
_method
;protected string
_module
;protected string
_controller
;protected string
_action
;protected array
_params
;protected string
_language
;protected string
_base_uri
;protected string
_request_uri
;protected boolean
_dispatched
;protected boolean
_routed
;public string getModuleName ( void );
public string getControllerName ( void );
public string getActionName ( void );
public boolean setModuleName ( string $name );
public boolean setControllerName ( string $name );
public boolean setActionName ( string $name );
public Exception getException ( void );
public mixed getParams ( void );
public mixed getParam ( string $name , mixed $dafault = NULL );
public mixed setParam ( string $name , mixed $value );
public mixed getMethod ( void );
abstract public mixed getLanguage ( void );
abstract public mixed getQuery ( string $name = NULL );
abstract public mixed getPost ( string $name = NULL );
abstract public mixed getEnv ( string $name = NULL );
abstract public mixed getServer ( string $name = NULL );
abstract public mixed getCookie ( string $name = NULL );
abstract public mixed getFiles ( string $name = NULL );
abstract public bool isGet ( void );
abstract public bool isPost ( void );
abstract public bool isHead ( void );
abstract public bool isXmlHttpRequest ( void );
abstract public bool isPut ( void );
abstract public bool isDelete ( void );
abstract public bool isOption ( void );
abstract public bool isCli ( void );
public bool isDispatched ( void );
public bool setDispatched ( void );
public bool isRouted ( void );
public bool setRouted ( void );
}
_method
当前请求的Method, 对于命令行来说, Method为"CLI"
_language
当前请求的希望接受的语言, 对于Http请求来说, 这个值来自分析请求头Accept-Language. 对于不能鉴别的情况, 这个值为NULL.
_module
在路由完成后, 请求被分配到的模块名
_controller
在路由完成后, 请求被分配到的控制器名
_action
在路由完成后, 请求被分配到的动作名
_params
当前请求的附加参数
_routed
表示当前请求是否已经完成路由
_dispatched
表示当前请求是否已经完成分发
_request_uri
当前请求的Request URI
_base_uri
当前请求Request URI要忽略的前缀, 一般不需要手工设置, Yaf会自己分析. 只是当Yaf分析出错的时候, 可以通过application.baseUri来手工设置.
The Yaf_Request_Http class
简介代表了一个实际的Http请求, 一般的不用自己实例化它, Yaf_Application在run以后会自动根据当前请求实例它
在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用 Yaf\Request_Http
final Yaf_Request_Http extends Yaf_Request_Abstract {属性说明public void __construct ( string $request_uri = NULL , string $base_uri = NULL );
public mixed getLanguage ( void );
public mixed getQuery ( string $name = NULL );
public mixed getPost ( string $name = NULL );
public mixed getEnv ( string $name = NULL );
public mixed getServer ( string $name = NULL );
public mixed getCookie ( string $name = NULL );
public mixed getFiles ( string $name = NULL );
public bool isGet ( void );
public bool isPost ( void );
public bool isHead ( void );
public bool isXmlHttpRequest ( void );
public bool isPut ( void );
public bool isDelete ( void );
public bool isOption ( void );
public bool isCli ( void );
public bool isDispatched ( void );
public bool setDispatched ( void );
public bool isRouted ( void );
public bool setRouted ( void );
public string getBaseUri ( void );
public boolean setBaseUri ( string $base_uri );
public string getRequestUri ( void );
}
The Yaf_Request_Simple class
简介代表了一个实际的请求, 一般的不用自己实例化它, Yaf_Application在run以后会自动根据当前请求实例它
在PHP5.3之后, 打开yaf.use_namespace的情况下, 也可以使用 Yaf\Request_Simple
final Yaf_Request_Simple extends Yaf_Request_Abstract {属性说明public void __construct ( string $module , string $controller , string $action , string $method , array $params = NULL );
public mixed getLanguage ( void );
public mixed getQuery ( string $name = NULL );
public mixed getPost ( string $name = NULL );
public mixed getEnv ( string $name = NULL );
public mixed getServer ( string $name = NULL );
public mixed getCookie ( string $name = NULL );
public mixed getFiles ( string $name = NULL );
public bool isGet ( void );
public bool isPost ( void );
public bool isHead ( void );
public bool isXmlHttpRequest ( void );
public bool isPut ( void );
public bool isDelete ( void );
public bool isOption ( void );
public bool isSimple ( void );
public bool isDispatched ( void );
public bool setDispatched ( void );
public bool isRouted ( void );
public bool setRouted ( void );
}