本文整理汇总了PHP中Yaf_Dispatcher::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Dispatcher::getRequest方法的具体用法?PHP Yaf_Dispatcher::getRequest怎么用?PHP Yaf_Dispatcher::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Dispatcher
的用法示例。
在下文中一共展示了Yaf_Dispatcher::getRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initLayout
public function _initLayout(Yaf_Dispatcher $dispatcher)
{
// Enable template layout only on admin
// TODO: make this more accurate
if (strpos($dispatcher->getRequest()->getRequestUri(), "admin") !== FALSE && strpos($dispatcher->getRequest()->getRequestUri(), "edit") === FALSE && strpos($dispatcher->getRequest()->getRequestUri(), "confirm") === FALSE && strpos($dispatcher->getRequest()->getRequestUri(), "logDetails") === FALSE) {
$path = Billrun_Factory::config()->getConfigValue('application.directory');
$view = new Yaf_View_Simple($path . '/views/layout');
$dispatcher->setView($view);
}
}
示例2: initYafBySooh
/**
*
* @param \Yaf_Dispatcher $dispatcher
* @param string $jqueryVer 使用的jquery文件,默认值:jquery-1.11.2.min.js
* @return view
*/
public static function initYafBySooh($dispatcher, $jqueryVer = 'jquery-1.11.2.min.js')
{
$router = $dispatcher->getRouter();
$router->addRoute("byVar", new \Yaf_Route_Supervar(SOOH_ROUTE_VAR));
\Yaf_Loader::getInstance()->registerLocalNameSpace($GLOBALS['CONF']['localLibs']);
$req = $dispatcher->getRequest();
$tmp = $req->get('__ONLY__');
if ($tmp == 'body') {
\SoohYaf\Viewext::$bodyonly = true;
}
$tmp = trim($req->get('__VIEW__'));
//html(default),wap, json
define('VIW_INC_PATH', APP_PATH . '/application/views/_inc/');
\SoohYaf\Viewext::$jqueryVer = $jqueryVer;
if (!empty($tmp)) {
$tmp = strtolower($tmp);
\Sooh\Base\Ini::getInstance()->viewRenderType($tmp);
if ($tmp == 'jsonp') {
\Sooh\Base\Ini::getInstance()->initGobal(array('nameJsonP' => $req->get('jsonp', 'jsonp')));
}
}
// $tmp = $dispatcher->getRequest()->get('__GZIP__');
// if(!empty($tmp)){
// $tmp = strtolower ($tmp);
// if($tmp=='gzip')define("ZIP_OUTPUT",$tmp);
// }
$view = new \SoohYaf\Viewext(null);
$dispatcher->setView($view);
$dispatcher->registerPlugin(new SoohPlugin());
return $view;
}
示例3: _initView
public function _initView(Yaf_Dispatcher $dispatcher)
{
$uri = $dispatcher->getRequest()->getRequestUri();
if ($uri) {
$uriArray = explode('/', $dispatcher->getRequest()->getRequestUri());
switch ($uriArray[1]) {
case 'admin':
$viewPath = APPLICATION_PATH . '/modules/Admin/views';
break;
default:
$viewPath = APPLICATION_PATH . '/views';
}
$view = new TwigAdapter($viewPath, Yaf_Registry::get('config')->get('twig')->toArray());
$dispatcher->setView($view);
}
}
示例4: _init
public function _init(Yaf_Dispatcher $dispatcher)
{
// auto start session
Yaf_Session::getInstance()->start();
// auto load config data
$this->config = Yaf_Application::app()->getConfig();
Yaf_Registry::set('Config', $this->config);
//auto load redis
$redis = new Redis();
$redis->connect($this->config->redis->host, $this->config->redis->port, $this->config->redis->timeout, $this->config->redis->reserved, $this->config->redis->interval);
Yaf_Registry::set('Redis', $redis);
//auto load mysql
Yaf_Registry::set('DbRead', new Db('mysql:host=' . $this->config->mysql->read->host . ';dbname=' . $this->config->mysql->read->dbname . ';charset=' . $this->config->mysql->read->charset . ';port=' . $this->config->mysql->read->port . '', $this->config->mysql->read->username, $this->config->mysql->read->password));
Yaf_Registry::set('DbWrite', new Db('mysql:host=' . $this->config->mysql->write->host . ';dbname=' . $this->config->mysql->write->dbname . ';charset=' . $this->config->mysql->write->charset . ';port=' . $this->config->mysql->write->port . '', $this->config->mysql->write->username, $this->config->mysql->write->password));
// auto load model
Yaf_Registry::set('I18n', new I18nModel($redis, $this->config->application->name, 'cn'));
Yaf_Registry::set('Cache', new CacheModel($redis, $this->config->application->name));
// auto load plugin
$dispatcher->registerPlugin(new GlobalPlugin());
// auto save request
$request = $dispatcher->getRequest();
// auto set ajax is no render
if ($request->isXmlHttpRequest()) {
$dispatcher->autoRender(false);
}
// auto set http protocol to action except http get protocol
if (!$request->isGet()) {
$dispatcher->setDefaultAction($request->getMethod());
}
}
示例5: _initConfig
public function _initConfig(Yaf_Dispatcher $dispatcher)
{
$this->config = Yaf_Application::app()->getConfig();
Yaf_Registry::set('config', $this->config);
//判断请求方式,命令行请求应跳过一些HTTP请求使用的初始化操作,如模板引擎初始化
define('REQUEST_METHOD', strtoupper($dispatcher->getRequest()->getMethod()));
Yaf_Loader::import(APPLICATION_PATH . '/conf/defines.inc.php');
}
示例6: _initRequest
public function _initRequest(Yaf_Dispatcher $dispatcher)
{
#if (!empty($this->_option) && !empty($this->_option['c']) && !empty($this->_option['a']))
# $dispatcher->getRequest()->setRequestUri($this->_option['c']."/".$this->_option['a']);
$dispatcher->getRequest()->setRequestUri(basename(APPLICATION_INDEX, ".php") . "/main");
}