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


PHP Yaf_Dispatcher::getInstance方法代碼示例

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


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

示例1: run

 public function run()
 {
     $this->groupTable = Sys_Database::getTable('worker');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $gid = $this->getRequest()->getPost('gid');
         $this->delete($gid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         if ($id) {
             $configDataTmp = $this->alarmModel->selectData($id, 1, 1, $this->groupTable);
             $configData = $configDataTmp[0];
         }
         $this->display('addworker', array('D' => $configData));
     }
     if ($this->getRequest()->getQuery('o') == 'add') {
         $this->add();
     }
     $page = $this->getRequest()->getQuery('p');
     $alarmList['page'] = $page ? $page : 1;
     $id = $this->getRequest()->getQuery('pluginid');
     $pid = $id ? $id : NULL;
     $limit = 20;
     $alarmList['list'] = $this->alarmModel->selectData($pid, ($alarmList['page'] - 1) * $limit, $limit, $this->groupTable);
     $alarmNum = $this->alarmModel->selectData($pid, -1, -1, $this->groupTable);
     $alarmList['num'] = $alarmNum['num'];
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
開發者ID:kaka987,項目名稱:YoungYaf,代碼行數:34,代碼來源:Worker.php

示例2: routerShutdown

 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $config = \Yaf_Registry::get('configarr');
     $dispatcher = Yaf_Dispatcher::getInstance();
     $twig = '';
     // view 放在module 目錄裏
     if ($request->module == $config['application']['dispatcher']['defaultModule']) {
         $twig = new \Core_Twig(APP_PATH . 'views', $config['twig']);
     } else {
         $twig = new \Core_Twig(APP_PATH . 'modules/' . $request->module . '/views', $config['twig']);
     }
     // url generate
     $twig->twig->addFunction("url", new Twig_Function_Function("Tools_help::url"));
     // 語言對應
     $twig->twig->addFunction("lang", new Twig_Function_Function("Tools_help::lang"));
     // 圖片路徑
     $twig->twig->addFunction("fbu", new Twig_Function_Function("Tools_help::fbu"));
     // 數字驗證
     $twig->twig->addFunction("is_numeric", new Twig_Function_Function("is_numeric"));
     // 處理錯誤提醒
     $session_key = array('ErrorMessageStop', 'ErrorMessage', 'Message');
     foreach ($session_key as $value) {
         $twig->assign($value, Tools_help::getSession($value));
         Tools_help::setSession($value, '');
     }
     $dispatcher->setView($twig);
 }
開發者ID:haobojunsun,項目名稱:d3,代碼行數:27,代碼來源:Twig.php

示例3: routerStartup

 /**
  * 路由分發開始
  *
  * @see Yaf_Plugin_Abstract::routerShutdown()
  */
 public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     //IIS不支持默認路由,采用URL Query String方式路由
     $router = Yaf_Dispatcher::getInstance()->getRouter();
     $route = new Yaf_Route_Simple('m', 'c', 'a');
     $router->addRoute('Windows-IIS-Supervar', $route);
 }
開發者ID:chaoyanjie,項目名稱:HiBlog,代碼行數:12,代碼來源:Iis.php

示例4: _initRoute

 function _initRoute()
 {
     # 路由
     $router = Yaf_Dispatcher::getInstance()->getRouter();
     # 靜態頁麵
     $router->addRoute('html', new Yaf_Route_Regex('/([a-z]+)\\.html$/', array('controller' => 'Index', 'action' => 'html'), array(1 => 'page')));
 }
開發者ID:tanqinwang,項目名稱:test_own,代碼行數:7,代碼來源:Bootstrap.php

示例5: init

 /**
  * 初始化 REST 路由
  * 修改操作 和 綁定參數
  * @method init
  * @author NewFuture
  */
 protected function init()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     //關閉視圖模板引擎
     $action = $this->_request->getActionName();
     //數字id映射帶info控製器
     if (is_numeric($action)) {
         $this->_request->setParam('id', intval($action));
         $path = substr(strstr($_SERVER['PATH_INFO'], $action), strlen($action) + 1);
         $action = $path ? strstr($path . '/', '/', true) : 'info';
         $this->_request->setActionName($action);
     }
     //對應REST_Action
     $method = $this->_request->getMethod();
     $rest_action = $method . '_' . $action;
     /*檢查該action操作是否存在,存在則修改為REST接口*/
     if (method_exists($this, $rest_action . 'Action')) {
         /*存在對應的操作*/
         $this->_request->setActionName($rest_action);
     } elseif (!method_exists($this, $action . 'Action')) {
         /*action和REST_action 都不存在*/
         $this->response = array('error' => '未定義操作', 'method' => $method, 'action' => $action, 'controller' => $this->_request->getControllerName());
         exit;
     }
     //put請求寫入GOLBAL中
     $method == 'PUT' and parse_str(file_get_contents('php://input'), $GLOBALS['_PUT']);
 }
開發者ID:wuxw,項目名稱:YYF,代碼行數:33,代碼來源:Rest.php

示例6: ScaffoldRoute

 /**
  *Scaffold action識配
  */
 protected function ScaffoldRoute()
 {
     if (!$this->Scaffold) {
         return;
     }
     $this->set('controller', $this->getRequest()->getControllerName());
     $this->allParams();
     Yaf_Dispatcher::getInstance()->disableView();
     $action = $this->getRequest()->getActionName();
     if ($action == 'c') {
         $this->scaffoldC = TRUE;
         $action = $this->getRequest()->getParam('action');
     }
     switch ($action) {
         case 'scaffoldajax':
             $this->ScaffoldAjax();
             break;
         case 'scaffold':
             $this->ScaffoldIndex();
             break;
         case 'getrow':
             $this->ScaffoldGetrow();
             break;
         case 'modify':
             $this->ScaffoldModify();
             break;
         case 'remove':
             $this->ScaffoldRemove();
             break;
         default:
             $this->ScaffoldIndex();
     }
 }
開發者ID:chenchengwork,項目名稱:Yaf.Scaffold,代碼行數:36,代碼來源:Scaffold.php

示例7: __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;
 }
開發者ID:nicevoice,項目名稱:yhtx,代碼行數:29,代碼來源:Application.php

示例8: init

 public function init()
 {
     if (Yaf_Session::getInstance()->has('username')) {
         $this->getView()->assign('username', Yaf_Session::getInstance()->offsetGet('username'));
     } else {
         return $this->redirect('/Login');
     }
     $dsn = 'mysql:host=127.0.0.1;dbname=yafdemo;charset=utf8';
     $username = 'root';
     $password = 'root';
     $dbo = new PDO($dsn, $username, $password);
     $dbo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     $dbo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     $dbo->exec('SET NAMES UTF8');
     $this->dbo = $dbo;
     $request = $this->getRequest();
     $module = strtolower($request->getModuleName());
     $controller = strtolower($request->getControllerName());
     $action = strtolower($request->getActionName());
     if (!$this->_checkPerm($module, $controller, $action) && $action != 'logout') {
         $this->getView()->setScriptPath(APPLICATION_PATH . "/application/views");
         $this->getView()->display('common/403.phtml');
         Yaf_Dispatcher::getInstance()->autoRender(FALSE);
         exit;
     }
 }
開發者ID:lifenglsf,項目名稱:yafdemo,代碼行數:26,代碼來源:Admin.php

示例9: _initRoute

 public function _initRoute()
 {
     $router = Yaf_Dispatcher::getInstance()->getRouter();
     // Article detail router [偽靜態]
     $route = new Yaf_Route_Rewrite('/article/detail/:articleID', array('controller' => 'article', 'action' => 'detail'));
     $router->addRoute('regex', $route);
 }
開發者ID:pan269,項目名稱:YOF,代碼行數:7,代碼來源:Bootstrap.php

示例10: testCase036

 /**
  * @runInSeparateProcess
  */
 public function testCase036()
 {
     $testData = array(0 => array('url' => '/', 'expected' => array('m' => null, 'c' => null, 'a' => null, 'args' => array())), 1 => array('url' => '/foo', 'expected' => array('m' => null, 'c' => 'foo', 'a' => null, 'args' => array())), 2 => array('url' => '/foo/', 'expected' => array('m' => null, 'c' => 'foo', 'a' => null, 'args' => array())), 3 => array('url' => '/foo///bar', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array())), 4 => array('url' => 'foo/bar', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array())), 5 => array('url' => '/foo/bar/', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array())), 6 => array('url' => '/foo/bar/dummy', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array('dummy' => null))), 7 => array('url' => '/foo///bar/dummy', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array('dummy' => null))), 8 => array('url' => 'foo/bar/dummy', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'bar', 'args' => array('dummy' => null))), 9 => array('url' => '/my', 'expected' => array('m' => null, 'c' => 'my', 'a' => null, 'args' => array())), 10 => array('url' => '/my/', 'expected' => array('m' => null, 'c' => 'my', 'a' => null, 'args' => array())), 11 => array('url' => '/my/foo', 'expected' => array('m' => null, 'c' => 'my', 'a' => 'foo', 'args' => array())), 12 => array('url' => '/my/foo/', 'expected' => array('m' => null, 'c' => 'my', 'a' => 'foo', 'args' => array())), 13 => array('url' => '/my/foo/bar', 'expected' => array('m' => 'my', 'c' => 'foo', 'a' => 'bar', 'args' => array())), 14 => array('url' => '/my/foo/bar/', 'expected' => array('m' => 'my', 'c' => 'foo', 'a' => 'bar', 'args' => array())), 15 => array('url' => '/my/foo/bar/dummy/1', 'expected' => array('m' => 'my', 'c' => 'foo', 'a' => 'bar', 'args' => array('dummy' => '1'))), 16 => array('url' => 'my/foo/bar/dummy/1/a/2/////', 'expected' => array('m' => 'my', 'c' => 'foo', 'a' => 'bar', 'args' => array('dummy' => '1', 'a' => '2'))), 17 => array('url' => '/my/index/index', 'expected' => array('m' => 'my', 'c' => 'index', 'a' => 'index', 'args' => array())), 18 => array('url' => '/my/index', 'expected' => array('m' => null, 'c' => 'my', 'a' => 'index', 'args' => array())), 19 => array('url' => '/foo/index', 'expected' => array('m' => null, 'c' => 'foo', 'a' => 'index', 'args' => array())), 20 => array('url' => 'index/foo', 'expected' => array('m' => null, 'c' => 'index', 'a' => 'foo', 'args' => array())));
     $config = array("application" => array("directory" => '/tmp/', "modules" => 'Index,My'));
     $app = new Yaf_Application($config);
     $route = Yaf_Dispatcher::getInstance()->getRouter();
     foreach ($testData as $index => $test) {
         $req = new Yaf_Request_Http($test['url']);
         $route->route($req);
         $this->assertEquals($test['expected']['m'], $req->getModuleName(), 'Failed module test for url:' . $test['url']);
         $this->assertEquals($test['expected']['c'], $req->getControllerName(), 'Failed controller test for url:' . $test['url']);
         $this->assertEquals($test['expected']['a'], $req->getActionName(), 'Failed action test for url:' . $test['url']);
         $this->assertEquals($test['expected']['args'], $req->getParams(), 'Failed param test for url:' . $test['url']);
     }
     if (!defined('YAF_MODE')) {
         Yaf_G::iniSet('yaf.action_prefer', true);
     } else {
         ini_set('yaf.action_prefer', true);
     }
     $testDataActionPrefer = array(0 => array('url' => '/', 'expected' => array('m' => null, 'c' => null, 'a' => null, 'args' => array())), 1 => array('url' => '/foo', 'expected' => array('m' => null, 'c' => null, 'a' => 'foo', 'args' => array())), 2 => array('url' => '/foo/', 'expected' => array('m' => null, 'c' => null, 'a' => 'foo', 'args' => array())), 3 => array('url' => '/my', 'expected' => array('m' => null, 'c' => 'my', 'a' => null, 'args' => array())), 4 => array('url' => '/my/', 'expected' => array('m' => null, 'c' => 'my', 'a' => null, 'args' => array())), 5 => array('url' => '/my/foo', 'expected' => array('m' => null, 'c' => 'my', 'a' => 'foo', 'args' => array())), 6 => array('url' => '/my//foo', 'expected' => array('m' => null, 'c' => 'my', 'a' => 'foo', 'args' => array())));
     foreach ($testDataActionPrefer as $index => $test) {
         $req = new Yaf_Request_Http($test['url']);
         $route->route($req);
         $this->assertEquals($test['expected']['m'], $req->getModuleName(), 'Failed module test for url:' . $test['url']);
         $this->assertEquals($test['expected']['c'], $req->getControllerName(), 'Failed controller test for url:' . $test['url']);
         $this->assertEquals($test['expected']['a'], $req->getActionName(), 'Failed action test for url:' . $test['url']);
         $this->assertEquals($test['expected']['args'], $req->getParams(), 'Failed param test for url:' . $test['url']);
     }
 }
開發者ID:ligboy,項目名稱:yaf-phpport,代碼行數:32,代碼來源:RouterTest.php

示例11: 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

示例12: 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

示例13: dispatchLoopStartup

 public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $view = new TZ_View();
     $view->setCacheEnable(true);
     $view->setScriptPath(APP_PATH . '/application/modules/' . $request->getModuleName() . '/views');
     Yaf_Dispatcher::getInstance()->setView($view);
 }
開發者ID:xiaoyueer98,項目名稱:store.heimi.com,代碼行數:7,代碼來源:Bootstrap.php

示例14: _initRoute

 /**
  * 路由規則定義,如果沒有需要,可以去除該代碼
  * 
  * @param Yaf_Dispatcher $dispatcher
  */
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $config = new Yaf_Config_Ini(APPLICATION_PATH . '/conf/route.ini', 'common');
     if ($config->routes) {
         $router = Yaf_Dispatcher::getInstance()->getRouter();
         $router->addConfig($config->routes);
     }
 }
開發者ID:liwei415,項目名稱:yaf_skeleton,代碼行數:13,代碼來源:Bootstrap.php

示例15: _initRoute

 /**
  *初始化路由
  */
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $router = Yaf_Dispatcher::getInstance()->getRouter();
     /**
      * 添加配置中的路由
      */
     $router->addConfig(Yaf_Registry::get("config")->routes);
 }
開發者ID:xiaofang520,項目名稱:agency,代碼行數:11,代碼來源:Bootstrap.php


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