当前位置: 首页>>代码示例>>PHP>>正文


PHP D::v方法代码示例

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


在下文中一共展示了D::v方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rpc

 public function rpc($cdata)
 {
     $classes = $this->_api->getClasses();
     D::v($this->_api);
     try {
         if (!isset($classes[$cdata->action])) {
             $good = FALSE;
             foreach ($classes as $classCheck => $cconfCheck) {
                 if (is_array($cconfCheck) && $cconfCheck['serverName'] == $cdata->action) {
                     $class = $classCheck;
                     $good = TRUE;
                 }
             }
             if (!$good) {
                 throw new Exception('Call to undefined class: ' . $cdata->action);
             }
         } else {
             $class = $cdata->action;
         }
         $method = $cdata->method;
         $cconf = $classes[$class];
         $mconf = null;
         $classPath = isset($cconf['fullPath']) ? $cconf['fullPath'] : $this->_api->getClassPath($class, $cconf);
         require_once $class . '.inc';
         $parsedAPI = $this->_api->getParsedAPI();
         if (!empty($parsedAPI) && isset($parsedAPI['actions'][$class])) {
             foreach ($parsedAPI['actions'][$class] as $m) {
                 if ($m['name'] === $method) {
                     $mconf = $m;
                     $serverMethod = isset($m['serverMethod']) ? $m['serverMethod'] : $method;
                 }
             }
         } else {
             // do some very simple reflection on the class to check if the method is allowed
             $rClass = new ReflectionClass($cconf['prefix'] . $class);
             if (!$rClass->hasMethod($method)) {
                 $rMethods = $rClass->getMethods();
                 foreach ($rMethods as $rMethod) {
                     $doc = $rMethod->getDocComment();
                     if ($rMethod->isPublic() && strlen($doc) > 0 && !!preg_match('/' . $this->_remoteAttribute . '/', $doc) && !!preg_match('/' . $this->_nameAttribute . ' ([w]+)/', $doc, $matches) && $method === $matches[1]) {
                         $serverMethod = $rMethod->getName();
                         $mconf = array('name' => $method, 'len' => $rMethod->getNumberOfRequiredParameters());
                         if (!!preg_match('/' . $this->_api->getFormAttribute() . '/', $doc)) {
                             $mconf['formHandler'] = true;
                         }
                     }
                 }
                 if (!$serverMethod) {
                     throw new Exception("Call to undefined method: {$method} on class {$class}");
                 }
             } else {
                 $rMethod = $rClass->getMethod($method);
                 $doc = $rMethod->getDocComment();
                 if ($rMethod->isPublic() && strlen($doc) > 0) {
                     if (!!preg_match('/' . $this->_api->getRemoteAttribute() . '/', $doc)) {
                         $serverMethod = $method;
                         $mconf = array('name' => $method, 'len' => $rMethod->getNumberOfRequiredParameters());
                         if (!!preg_match('/' . $this->_api->getFormAttribute() . '/', $doc)) {
                             $mconf['formHandler'] = true;
                         }
                     }
                 }
             }
         }
         if (!isset($mconf)) {
             throw new Exception("Call to undefined or unallowed method: {$method} on class {$class}");
         }
         if ($this->isForm && (!isset($mconf['formHandler']) || $mconf['formHandler'] !== true)) {
             throw new Exception("Called method {$method} on class {$class} is not a form handler");
         }
         $params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array();
         if (count($params) < $mconf['len']) {
             throw new Exception("Not enough required params specified for method: {$method} on class {$class}");
         }
         if ($cconf['serverName']) {
             $action = $cconf['serverName'];
         } else {
             $action = $class;
         }
         $response = array('type' => 'rpc', 'tid' => $cdata->tid, 'action' => $action, 'method' => $method);
         $className = $cconf['prefix'] . $class;
         $instance = new $className();
         $response['result'] = call_user_func_array(array($instance, $serverMethod), $params);
     } catch (Exception $e) {
         $response = array('type' => 'exception', 'tid' => $cdata->tid, 'message' => $e->getMessage(), 'where' => $e->getTraceAsString());
     }
     return $response;
 }
开发者ID:twelvefootguru,项目名称:anApp,代码行数:88,代码来源:Router.php

示例2: addIncludePath

$configFile = 'common/config.inc';
include_once "./alib/alib.inc";
global $debug, $config;
addIncludePath('./alib');
addIncludePath('./common');
addIncludePath('./php', TRUE);
include_once '../alib/iuser.inc';
include_once './common/functions.inc';
include_once './common/login.inc';
include_once './common/smartObjectDefs.inc';
// Connect to the db:
if (!is_object($db)) {
    $db = new idb($config->mainDB);
}
D::log('db');
D::v($db);
$login = new $config->loginModule();
if ($login->loggedIn || $config->allowNonLoggedIn) {
    global $user, $broker;
    $broker = new broker();
} elseif (stristr($_SERVER['REQUEST_URI'], 'api')) {
    $api = new publicAPI();
} else {
    $template = new template($config->loginTemplate);
    $template->set('title', $config->defaultTitle);
    $template->set('appName', $config->appName);
    $template->set('extLocation', $config->extLocation);
    $template->set('self', $config->self);
    if ($login->error && $login->error != 'Not logged in and not trying to log in.') {
        $template->set('badLogin', TRUE);
        $template->set('loginError', $login->error);
开发者ID:twelvefootguru,项目名称:anApp,代码行数:31,代码来源:index.php


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