• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Yaf_Dispatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Yaf_Dispatcher的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Dispatcher类的具体用法?PHP Yaf_Dispatcher怎么用?PHP Yaf_Dispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Yaf_Dispatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: _initLayout

 public function _initLayout(Yaf_Dispatcher $dispatcher)
 {
     /*layout allows boilerplate HTML to live in /views/layout rather than every script*/
     $layout = new LayoutPlugin('layout.phtml');
     /* Store a reference in the registry so values can be set later.
      * This is a hack to make up for the lack of a getPlugin
      * method in the dispatcher.
      */
     Yaf_Registry::set('layout', $layout);
     /*add the plugin to the dispatcher*/
     $dispatcher->registerPlugin($layout);
 }
开发者ID:haokee,项目名称:Yaf-PHP-Example,代码行数:12,代码来源:Bootstrap.php


示例17: _initLayout

 /**
  * 采用布局
  * @param Yaf_Dispatcher $dispatcher
  */
 function _initLayout(Yaf_Dispatcher $dispatcher)
 {
     define('REDIRECT_URL', empty($_SERVER['REQUEST_URI']) ? '/' : strtolower($_SERVER['REQUEST_URI']));
     # 用户后台
     if (false !== strpos(REDIRECT_URL, '/user_emailverify')) {
         return;
     }
     if (false !== strpos(REDIRECT_URL, '/user_') || false !== strpos(REDIRECT_URL, '/huodong_') || false !== strpos(REDIRECT_URL, '/loan_')) {
         $layout = new LayoutPlugin('user/tpl.layout.phtml');
         Yaf_Registry::set('layout', $layout);
         $dispatcher->registerPlugin($layout);
     }
 }
开发者ID:tanqinwang,项目名称:test_own,代码行数:17,代码来源:Bootstrap.php


示例18: _initRoute

 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $router = $dispatcher->getRouter();
     //$router->addConfig(Yaf_Registry::get("config")->routes);
     //$route = new Yaf_Route_Rewrite(
     //	'exp/:ident',
     //	array(
     //		'controller' =>'index',
     //		'action' => 'index'
     //	)
     //);
     //$router -> addRoute('exp',$route);
     $route = new Yaf_Route_Rewrite('/admin/:action/:id', array('controller' => 'admin', 'action' => ':action'));
     $router->addRoute('name', $route);
 }
开发者ID:lifenglsf,项目名称:yafdemo,代码行数:15,代码来源:Bootstrap.php


示例19: init

 /**
  * Controller的init方法会被自动首先调用
  */
 public function init()
 {
     //调试mysql
     if (isset($_GET['debug6429360'])) {
         $this->debug = true;
         DB_Mysqli::$DEBUG = 1;
     }
     $this->platform = isset($_REQUEST['platform']) ? $_REQUEST['platform'] : $this->platform;
     Yaf_Registry::set("platform", $this->platform);
     $this->isMobile = $this->platform == 'ios' || $this->platform == 'android';
     $this->wap = !$this->isMobile && Common_Mobile::isMobile();
     $this->uid = $this->get('uid', $this->post('uid', false));
     $this->controllerName = $this->getRequest()->getControllerName();
     $this->actionName = $this->getRequest()->getActionName();
     $userModel = new UserModel();
     /*        if (!isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName])
                 && $this->isMobile 
                 && $this->needLogin 
                 && !$this->debug) 
             {
                 $token = $this->get("token", $this->post("token", false));
                 if (!$token) {
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN_NOT_EXISTS);
                 }
     
                 $api = $this->getRequestApi();
                 $check = Common_Token::check($token, $this->uid, strtolower($api));
                 if (!$check) {          
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN);
                 }
             }*/
     $this->uid = $this->uid ? $this->uid : $userModel->getUid();
     /**
      * 如果是Ajax请求, 则关闭HTML输出
      */
     if ($this->getRequest()->isXmlHttpRequest() || 'POST' == $this->getRequest()->getMethod()) {
         $this->ajax = true;
         Yaf_Dispatcher::getInstance()->disableView();
     } else {
         //$path = $this->getView()->getScriptPath();
         //$path[0] = $path[0] . "/" . strtolower($this->getRequest()->getControllerName());
         //$this->getView()->setScriptPath($path[0]);
     }
     //print_r($this->uid?$this->uid:"null");
     //验证登录
     /*if (
                 !isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName]) 
                 && $this->needLogin 
                 && !$this->uid) {
                 $this->redirect("/user/login?from=" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""), Common_Error::ERROR_USER_NOT_LOGIN);
     
                 $this->redirect("/user/verify", Common_Error::ERROR_USER_NOT_LOGIN);
             }*/
     //用户信息
     /*        if($this->uid) {
                 $user = $userModel->getUser($this->uid);
                 $this->assign("uInfo", $user);
                 Yaf_Registry::set("uid", $this->uid);
             }*/
 }
开发者ID:krisrita,项目名称:udo,代码行数:63,代码来源:Contr.php


示例20: errorAction

 function errorAction($exception)
 {
     // fallback views path to global when error occured in modules.
     $config = Yaf_Application::app()->getConfig();
     $this->getView()->setScriptPath($config->application->directory . "/views");
     $this->getView()->e = $exception;
     $this->getView()->e_class = get_class($exception);
     $this->getView()->e_string_trace = $exception->getTraceAsString();
     $params = $this->getRequest()->getParams();
     unset($params['exception']);
     $this->getView()->params = array_merge(array(), $params, $this->getRequest()->getPost(), $this->getRequest()->getQuery());
     switch ($exception->getCode()) {
         case YAF_ERR_AUTOLOAD_FAILED:
         case YAF_ERR_NOTFOUND_MODULE:
         case YAF_ERR_NOTFOUND_CONTROLLER:
         case YAF_ERR_NOTFOUND_ACTION:
             header('HTTP/1.1 404 Not Found');
             break;
         case 401:
             $this->forward('Index', 'application', 'accessDenied');
             header('HTTP/1.1 401 Unauthorized');
             Yaf_Dispatcher::getInstance()->disableView();
             echo $this->render('accessdenied');
             break;
         default:
             //header("HTTP/1.1 500 Internal Server Error");
             core::dump($exception);
             break;
     }
 }
开发者ID:290329416,项目名称:guahao,代码行数:30,代码来源:Error.php



注:本文中的Yaf_Dispatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Yaf_Loader类代码示例发布时间:2022-05-23
下一篇:
PHP Yaf_Application类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap