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


PHP Pi::piCallMethod方法代碼示例

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


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

示例1: dispatch

 public function dispatch()
 {
     if (!$this->checkSign()) {
         $this->output('api.err sign', 7099);
     }
     $mod_name = Pcf::get("global.mod", 'mod');
     $func_name = Pcf::get("global.func", 'func');
     $mod_seg = Pcf::get("global.mod_seg", '/');
     $api_path = Pcf::get("global.base_path", PI_APP_ROOT . PI_APP_NAME . DOT . 'logic' . DOT);
     $mod = Comm::Req($mod_name);
     $func = Comm::Req($func_name);
     $mod = explode($mod_seg, $mod);
     $pattern = '/^[0-9a-zA-Z\\/]*$/';
     $class = '';
     if (!empty($mod)) {
         foreach ($mod as $k => $m) {
             if (empty($m) || !is_string($m)) {
                 if (!preg_match($pattern, $m)) {
                     $this->output('api.err error format mod:' . $m, 1005);
                 }
                 unset($mod[$k]);
             }
             $mod[$k] = strtolower($m);
             $class .= ucfirst($mod[$k]);
         }
     }
     if (empty($mod)) {
         $this->output('api.err empty api mod:' . $mod, 1006);
     }
     if (empty($func) || !is_string($func) || !preg_match($pattern, $func)) {
         $this->output('api.err empty or error api func:' . $func, 1007);
     }
     Pi::inc(PI_CORE . 'BaseApi.php');
     $file = $api_path . implode(DOT, $mod) . DOT . $class . '.api.php';
     if (!Pi::inc($file)) {
         $this->output('api.err api router can not load file:' . $file, 1008);
     }
     if (!class_exists($class)) {
         $this->output('api.err api router not find class:' . $class, 1009);
     }
     $cls = new $class();
     if (!is_subclass_of($cls, 'PiBaseApi')) {
         $this->output('api.err is not the subclass of BaseApi', 1010);
     }
     if (!is_callable(array($cls, $func))) {
         $this->output('api.err api class:' . $class . ' can not call method:' . $func, 1011);
     }
     $res = Pi::piCallMethod($cls, $func);
     return $res;
 }
開發者ID:hihus,項目名稱:pi,代碼行數:50,代碼來源:ApiRouter.php

示例2: dispatch

 public function dispatch($url = null, $domain = '')
 {
     //正常邏輯保證按照目錄邏輯加載,需要美化url用path_info傳遞參數的需要自定義路由配置(保持高效)
     //ajax自動去掉第一層,然後按照路徑加載,二級域名去掉第一層,給域名定義alias配置,否則按照二級域名尋找
     if ($url != null) {
         $this->customRouter($url, $domain);
     }
     $uri = empty($this->uri) ? array() : explode('/', $this->uri);
     //如果沒有任何path info,走默認配置,沒有配置改成index
     if (empty($uri)) {
         $this->mod = array(Pcf::get('global.main_page', 'index'));
         $this->func = Pcf::get('global.main_func', 'index');
     } else {
         if (count($uri) == 1 && !empty($uri[0])) {
             $this->mod = array($uri[0]);
             $this->func = Pcf::get('global.main_func', 'index');
         } else {
             $this->func = array_pop($uri);
             $this->mod = $uri;
         }
     }
     //保護不讓訪問的頁麵
     if (isset($this->prtected[$this->func])) {
         throw new Exception('router.err can not reach the protected ctr', 1021);
     }
     $mod_path = '';
     $cls = '';
     foreach ($this->mod as $mod) {
         $mod_path = $mod_path . $mod . DOT;
         $cls = $cls . ucfirst($mod);
     }
     $cls = $this->class_pre . $cls . "Ctr";
     $file_path = $this->base_path . $mod_path . $cls . '.php';
     if (!Pi::inc($file_path)) {
         throw new Exception('router.err not found the router file : ' . $file_path, 1022);
     }
     if (!class_exists($cls)) {
         throw new Exception('router.err not found the router class: ' . $cls, 1023);
     }
     //執行
     $class = new $cls();
     if (!is_subclass_of($class, 'PiPageCtr')) {
         throw new Exception('router.err class : ' . $cls . 'is not the subclass of PiPageCtr', 1023);
     }
     try {
         Pi::piCallMethod($class, '_p_before');
         Pi::piCallMethod($class, 'initTmpl');
         Pi::piCallMethod($class, 'setRouter', array($this));
         if ($this->class_pre === 'Ajax') {
             Pi::piCallMethod($class, 'setAjax', array(true));
         }
         Pi::piCallMethod($class, '_before');
         if (substr($this->func, 0, 1) == '_' || !is_callable(array($class, $this->func))) {
             throw new Exception('router.err not ' . $cls . ' can not call : ' . $this->func, 1025);
         }
         Pi::piCallMethod($class, $this->func);
         Pi::piCallMethod($class, '_after');
         Pi::piCallMethod($class, '_p_after');
     } catch (Exception $ex) {
         Pi::piCallMethod($class, '_after');
         Pi::piCallMethod($class, '_p_after');
         throw $ex;
     }
 }
開發者ID:hihus,項目名稱:pi,代碼行數:64,代碼來源:RouteDispatcher.php


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