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


PHP Zend_Loader::LoadClass方法代碼示例

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


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

示例1: _dispatch

 /**
  * Loads a remote class or method and executes the function and returns
  * the result
  *
  * @param  string $method Is the method to execute
  * @param  mixed $param values for the method
  * @return mixed $response the result of executing the method
  * @throws Zend_Amf_Server_Exception
  */
 protected function _dispatch($method, $params = null, $source = null)
 {
     if (!isset($this->_table[$method])) {
         // if source is null a method that was not defined was called.
         if ($source) {
             $classPath = array();
             $path = explode('.', $source);
             $className = array_pop($path);
             $uriclasspath = implode('/', $path);
             // Take the user supplied directories and add the unique service path to the end.
             foreach ($this->_directories as $dir) {
                 $classPath[] = $dir . $uriclasspath;
             }
             require_once 'Zend/Loader.php';
             try {
                 Zend_Loader::LoadClass($className, $classPath);
             } catch (Exception $e) {
                 require_once 'Zend/Amf/Server/Exception.php';
                 throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist');
             }
             // Add the new loaded class to the server.
             $this->setClass($className);
         } else {
             require_once 'Zend/Amf/Server/Exception.php';
             throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
         }
     }
     $info = $this->_table[$method];
     $argv = $info->getInvokeArguments();
     if (0 < count($argv)) {
         $params = array_merge($params, $argv);
     }
     if ($info instanceof Zend_Server_Reflection_Function) {
         $func = $info->getName();
         $return = call_user_func_array($func, $params);
     } elseif ($info instanceof Zend_Server_Reflection_Method) {
         // Get class
         $class = $info->getDeclaringClass()->getName();
         if ('static' == $info->isStatic()) {
             // for some reason, invokeArgs() does not work the same as
             // invoke(), and expects the first argument to be an object.
             // So, using a callback if the method is static.
             $return = call_user_func_array(array($class, $info->getName()), $params);
         } else {
             // Object methods
             try {
                 $object = $info->getDeclaringClass()->newInstance();
             } catch (Exception $e) {
                 require_once 'Zend/Amf/Server/Exception.php';
                 throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName(), 621);
             }
             $return = $info->invokeArgs($object, $params);
         }
     } else {
         require_once 'Zend/Amf/Server/Exception.php';
         throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
     }
     return $return;
 }
開發者ID:Velrok,項目名稱:wg-organizer,代碼行數:68,代碼來源:Server.php


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