本文整理汇总了PHP中Yaf_Dispatcher::setRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Dispatcher::setRequest方法的具体用法?PHP Yaf_Dispatcher::setRequest怎么用?PHP Yaf_Dispatcher::setRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Dispatcher
的用法示例。
在下文中一共展示了Yaf_Dispatcher::setRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$app = self::app();
if (!is_null($app)) {
throw new Yaf_Exception('Only one application can be initialized');
}
Yaf_G::init();
//这里主要是配置文件的加载
// request initialization
if (isset($_SERVER['REQUEST_METHOD'])) {
//判断http请求还是cli请求
$request = new Yaf_Request_Http();
//获取请求的url路径和基础路径,以及请求方式
} else {
$request = new Yaf_Request_Cli();
}
if ($request == null) {
throw new Yaf_Exception('Initialization of request failed');
}
// dispatcher
$this->_dispatcher = Yaf_Dispatcher::getInstance();
//将调度对象赋值给app对象的属性,并在调度对象的属性中添加路由对象,单例
if ($this->_dispatcher == null || !$this->_dispatcher instanceof Yaf_Dispatcher) {
throw new Yaf_Exception('Instantiation of dispatcher failed');
}
$this->_dispatcher->setRequest($request);
//把请求对象赋值给调度对象的属性中
self::$_app = $this;
}
示例2: __construct
public function __construct($config, $env = null)
{
$app = self::app();
if (!is_null($app)) {
throw new Yaf_Exception_StartupError('Only one application can be initialized');
}
$this->_environ = $env;
$config = $this->_loadConfig($config);
if ($config == null || !$config instanceof Yaf_Config_Abstract || $this->parseOptions($config->toArray()) != true) {
throw new Yaf_Exception_StartupError('Initialization of application config failed');
}
//$this->parseOptions($config->toArray());
$this->_config = $config;
//request initialization
$request = new Yaf_Request_Http();
if ($request == null) {
throw new Yaf_Exception_StartupError('Initialization of request failed');
}
//dispatcher
$this->_dispatcher = Yaf_Dispatcher::getInstance();
if ($this->_dispatcher == null || !$this->_dispatcher instanceof Yaf_Dispatcher) {
throw new Yaf_Exception_StartupError('Instantiation of dispatcher failed');
}
$this->_dispatcher->setRequest($request);
//loader initialization
$loader = Yaf_Loader::getInstance(isset($this->_options['local_library']) ? $this->_options['local_library'] : '', Yaf_G::iniGet('yaf.library'));
if ($loader == null || !$loader instanceof Yaf_Loader) {
throw new Yaf_Exception_StartupError('Initialization of application auto loader failed');
}
if (isset($this->_options['local_namespace']) && $this->_options['local_namespace'] != '') {
$namespace = str_replace(array(',', ' '), array(':', ':'), $this->_options['local_namespace']);
$loader->registerLocalNamespace($namespace);
}
self::$_app = $this;
if (Yaf_G::get('throwException') == false) {
set_exception_handler(array($this, 'exceptionHandler'));
}
}