本文整理汇总了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;
}