本文整理匯總了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'));
}
}