當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Yaf_Dispatcher類代碼示例

本文整理匯總了PHP中Yaf_Dispatcher的典型用法代碼示例。如果您正苦於以下問題:PHP Yaf_Dispatcher類的具體用法?PHP Yaf_Dispatcher怎麽用?PHP Yaf_Dispatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Yaf_Dispatcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _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());
     }
 }
開發者ID:a707937337,項目名稱:helloword,代碼行數:30,代碼來源:Bootstrap.php

示例2: _initRoute

 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     // 編輯員工
     $dispatcher->getRouter()->addRoute('staffUpdateRewrite', new Yaf_Route_Rewrite('/admin/staff/update/:userId', array('module' => 'admin', 'controller' => 'staff', 'action' => 'update')));
     // 刪除員工
     $dispatcher->getRouter()->addRoute('staffDeleteRewrite', new Yaf_Route_Rewrite('/admin/staff/delete/:userId', array('module' => 'admin', 'controller' => 'staff', 'action' => 'delete')));
 }
開發者ID:yinliguo,項目名稱:phpBase,代碼行數:7,代碼來源:Bootstrap.php

示例3: _initSmarty

 public function _initSmarty(Yaf_Dispatcher $dispatcher)
 {
     /* init smarty view engine */
     Yaf_Loader::import("Smarty/Adapter.php");
     $smarty = new Smarty_Adapter(null, Yaf_Application::app()->getConfig()->smarty);
     $dispatcher->setView($smarty);
 }
開發者ID:gangjun911,項目名稱:yaf-examples,代碼行數:7,代碼來源:Bootstrap.php

示例4: 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;
 }
開發者ID:hillstill,項目名稱:soohyaf,代碼行數:37,代碼來源:SoohPlugin.php

示例5: _initRoutes

 /**
  * [路由設置]
  */
 public function _initRoutes(Yaf_Dispatcher $dispatcher)
 {
     $router = $dispatcher->getRouter();
     //$router->addConfig(Yaf_Registry::get('config')->routes);
     Yaf_Loader::import(APP_CONFIG . '/route.php');
     $router->addConfig($routeConfigs);
 }
開發者ID:zhangxinvip,項目名稱:YafUse,代碼行數:10,代碼來源:Bootstrap.php

示例6: _initPlugin

 function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     Yaf_Loader::import('vendor/autoload.php');
     $dispatcher->registerPlugin(new Plugin_Init());
     $dispatcher->registerPlugin(new Plugin_Smarty());
     $dispatcher->registerPlugin(new LoginPlugin());
 }
開發者ID:Zjmainstay,項目名稱:php-doc-management,代碼行數:7,代碼來源:Bootstrap.php

示例7: _initView

 protected function _initView(Yaf_Dispatcher $dispatcher)
 {
     $view = new YafView(APPLICATION_VIEW_SCRIPTS_PATH);
     $view->enableLayout('layout/normal.phtml');
     $dispatcher->setView($view);
     //        $dispatcher->setView(new YafView(APPLICATION_VIEW_SCRIPTS_PATH));
 }
開發者ID:YexuanGuo,項目名稱:php-cms,代碼行數:7,代碼來源:Bootstrap.php

示例8: _initPlugin

 /**
  * 初始化plugin(插件)
  */
 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     //注冊xhprof插件
     if (isset($this->_config->application->xhprof) && $this->_config->application->xhprof) {
         $XHProf = new XHProfPlugin();
         $dispatcher->registerPlugin($XHProf);
     }
 }
開發者ID:RamboLau,項目名稱:yaf.framework,代碼行數:11,代碼來源:Bootstrap.php

示例9: _initPlugin

 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     $router = new RouterPlugin();
     $dispatcher->registerPlugin($router);
     $admin = new AdminPlugin();
     $dispatcher->registerPlugin($admin);
     Yaf_Registry::set('adminPlugin', $admin);
 }
開發者ID:xinuxZ,項目名稱:YOF,代碼行數:8,代碼來源:Bootstrap.php

示例10: _initDefaultName

 public function _initDefaultName(Yaf_Dispatcher $dispatcher)
 {
     //echo "_initDefaultName call last<br/>\n";
     /**
      * actully this is unecessary, since all the parameters here is the default value of Yaf
      */
     $dispatcher->setDefaultModule("Index")->setDefaultController("Index")->setDefaultAction("index");
 }
開發者ID:agui2200,項目名稱:yaf,代碼行數:8,代碼來源:Bootstrap.php

示例11: _initView

 public function _initView(Yaf_Dispatcher $dispatcher)
 {
     //在這裏注冊自己的view控製器,例如smarty,firekylin
     $smarty = new Smarty_Adapter(null, Yaf_Registry::get("config")->get("smarty"));
     Yaf_Registry::set("smarty", $smarty);
     $dispatcher->setView($smarty);
     //Yaf_Dispatcher::getInstance()->disableView();
     //var_dump('sssss');
 }
開發者ID:hexing-w,項目名稱:flower-yaf,代碼行數:9,代碼來源:Bootstrap.php

示例12: _initPlugin

 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     //echo 'aaa';
     //include (APP_PATH.'/plugins/UserPlugin.php');
     $user = new UserPlugin();
     //        echo 'cccc';
     $dispatcher->registerPlugin($user);
     //echo 'fff';
 }
開發者ID:phpcandy,項目名稱:phpcandy.github.io,代碼行數:9,代碼來源:bootstrap.php

示例13: _initRoute

 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     //在這裏注冊自己的路由協議,默認使用簡單路由
     $fileName = APPLICATION_PATH . "/conf/routes.ini";
     if (file_exists($fileName)) {
         $config = new Yaf_Config_Ini($fileName);
         $dispatcher->getRouter()->addConfig($config->routes);
     }
 }
開發者ID:stonegithubs,項目名稱:swoole-game,代碼行數:9,代碼來源:Bootstrap.php

示例14: _initRoute

 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     //在這裏注冊自己的路由協議,默認使用簡單路由
     $router = $dispatcher->getRouter();
     //創建一個路由協議實例
     $router->addRoute('index', new Yaf_Route_Regex('#^/$#', array('controller' => 'index', 'action' => 'index')));
     $router->addRoute('country', new Yaf_Route_Rewrite('route/:country', array('controller' => 'router', 'action' => 'country')));
     $router->addRoute('province', new Yaf_Route_Rewrite('route/:country/:province', array('controller' => 'router', 'action' => 'province')));
     $router->addRoute('city', new Yaf_Route_Rewrite('route/:country/:province/:city', array('controller' => 'router', 'action' => 'city')));
 }
開發者ID:jixiaod,項目名稱:yaf-swoole-framework,代碼行數:10,代碼來源:Bootstrap.php

示例15: 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;
 }
開發者ID:liu33851861,項目名稱:CZD_Yaf_Extension,代碼行數:16,代碼來源:Dispatcher.php


注:本文中的Yaf_Dispatcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。