本文整理汇总了PHP中Yaf_Dispatcher::setDefaultAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Dispatcher::setDefaultAction方法的具体用法?PHP Yaf_Dispatcher::setDefaultAction怎么用?PHP Yaf_Dispatcher::setDefaultAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Dispatcher
的用法示例。
在下文中一共展示了Yaf_Dispatcher::setDefaultAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetDefaultAction
public function testSetDefaultAction()
{
$this->dispatcher = Yaf_Dispatcher::getInstance();
$this->assertEquals('index', $this->readAttribute($this->dispatcher, '_default_action'));
$this->dispatcher->setDefaultAction('test');
$this->assertEquals('test', $this->readAttribute($this->dispatcher, '_default_action'));
//set back to index
$this->dispatcher->setDefaultAction('index');
}
示例2: getInstance
/**
* Singleton instance
*
* @return Yaf_Dispatcher
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
self::$_instance->setDefaultAction(Yaf_G::get('default_action'));
self::$_instance->setDefaultController(Yaf_G::get('default_controller'));
self::$_instance->setDefaultModule(Yaf_G::get('default_module'));
self::$_instance->_router = new Yaf_Router();
}
return self::$_instance;
}
示例3: _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());
}
}