本文整理汇总了PHP中Zend_Server_Reflection类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Server_Reflection类的具体用法?PHP Zend_Server_Reflection怎么用?PHP Zend_Server_Reflection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Server_Reflection类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setClass
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)) {
throw new Cosmos_Api_Server_Exception('Invalid method class', 610);
}
$argv = null;
if (2 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 2);
}
$dispatchable = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
foreach ($dispatchable->getMethods() as $reflection) {
$this->_buildSignature($reflection, $class);
}
}
开发者ID:EvanDotPro,项目名称:cosmos,代码行数:15,代码来源:Local.php
示例2: setClass
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && class_exists($class) || is_object($class)) {
// Get args.
$argv = null;
if (2 < func_num_args()) {
$argv = array_slice(func_get_args(), 2);
}
// Get namespace.
if ($namespace == '') {
$namespace = is_object($class) ? get_class($class) : $class;
}
// Validate namespace.
if (!new $namespace() instanceof phpMyWave_AbstractRobot) {
throw new Exception('Invalid method or class; must be instace of phpMyWave_AbstractRobot');
}
// Reflect class.
$this->_robots[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
} else {
throw new Exception('Invalid method or class; must be a classname or object');
}
return $this;
}
开发者ID:phpmywave,项目名称:phpMyWave,代码行数:23,代码来源:Server.php
示例3: addFunction
/**
* Attach a function to the server
*
* Additional arguments to pass to the function at dispatch may be passed;
* any arguments following the namespace will be aggregated and passed at
* dispatch time.
*
* @param string|array $function Valid callback
* @param string $namespace Optional namespace prefix
* @return Zend_Amf_Server
* @throws Zend_Amf_Server_Exception
*/
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && !is_array($function)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Unable to attach function');
}
$argv = null;
if (2 < func_num_args()) {
$argv = array_slice(func_get_args(), 2);
}
$function = (array) $function;
foreach ($function as $func) {
if (!is_string($func) || !function_exists($func)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Unable to attach function');
}
$this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
}
$this->_buildDispatchTable();
return $this;
}
开发者ID:raffpaquin,项目名称:Gregory,代码行数:33,代码来源:Server.php
示例4: testReflectFunction2
/**
* reflectFunction() test; test namespaces
*/
public function testReflectFunction2()
{
$reflection = Zend_Server_Reflection::reflectFunction('Zend_Server_Reflection_testFunction', false, 'zsr');
$this->assertEquals('zsr', $reflection->getNamespace());
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:8,代码来源:ReflectionTest.php
示例5: introspect
/**
* Create XML definition on an AMF service class
*
* @param string $serviceClass Service class name
* @param array $options invocation options
* @return string XML with service class introspection
*/
public function introspect($serviceClass, $options = array())
{
$this->_options = $options;
if (strpbrk($serviceClass, '\\/<>')) {
return $this->_returnError('Invalid service name');
}
// Transform com.foo.Bar into com_foo_Bar
$serviceClass = str_replace('.', '_', $serviceClass);
// Introspect!
if (!class_exists($serviceClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
}
$serv = $this->_xml->createElement('service-description');
$serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
$this->_types = $this->_xml->createElement('types');
$this->_ops = $this->_xml->createElement('operations');
$r = Zend_Server_Reflection::reflectClass($serviceClass);
$this->_addService($r, $this->_ops);
$serv->appendChild($this->_types);
$serv->appendChild($this->_ops);
$this->_xml->appendChild($serv);
return $this->_xml->saveXML();
}
开发者ID:robeendey,项目名称:ce,代码行数:31,代码来源:Introspector.php
示例6: upgrade_plugin_mnet_functions
/**
* upgrades the mnet rpc definitions for the given component.
* this method doesn't return status, an exception will be thrown in the case of an error
*
* @param string $component the plugin to upgrade, eg auth_mnet
*/
function upgrade_plugin_mnet_functions($component) {
global $DB, $CFG;
list($type, $plugin) = core_component::normalize_component($component);
$path = core_component::get_plugin_directory($type, $plugin);
$publishes = array();
$subscribes = array();
if (file_exists($path . '/db/mnet.php')) {
require_once($path . '/db/mnet.php'); // $publishes comes from this file
}
if (empty($publishes)) {
$publishes = array(); // still need this to be able to disable stuff later
}
if (empty($subscribes)) {
$subscribes = array(); // still need this to be able to disable stuff later
}
static $servicecache = array();
// rekey an array based on the rpc method for easy lookups later
$publishmethodservices = array();
$subscribemethodservices = array();
foreach($publishes as $servicename => $service) {
if (is_array($service['methods'])) {
foreach($service['methods'] as $methodname) {
$service['servicename'] = $servicename;
$publishmethodservices[$methodname][] = $service;
}
}
}
// Disable functions that don't exist (any more) in the source
// Should these be deleted? What about their permissions records?
foreach ($DB->get_records('mnet_rpc', array('pluginname'=>$plugin, 'plugintype'=>$type), 'functionname ASC ') as $rpc) {
if (!array_key_exists($rpc->functionname, $publishmethodservices) && $rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 0, array('id' => $rpc->id));
} else if (array_key_exists($rpc->functionname, $publishmethodservices) && !$rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 1, array('id' => $rpc->id));
}
}
// reflect all the services we're publishing and save them
require_once($CFG->dirroot . '/lib/zend/Zend/Server/Reflection.php');
static $cachedclasses = array(); // to store reflection information in
foreach ($publishes as $service => $data) {
$f = $data['filename'];
$c = $data['classname'];
foreach ($data['methods'] as $method) {
$dataobject = new stdClass();
$dataobject->plugintype = $type;
$dataobject->pluginname = $plugin;
$dataobject->enabled = 1;
$dataobject->classname = $c;
$dataobject->filename = $f;
if (is_string($method)) {
$dataobject->functionname = $method;
} else if (is_array($method)) { // wants to override file or class
$dataobject->functionname = $method['method'];
$dataobject->classname = $method['classname'];
$dataobject->filename = $method['filename'];
}
$dataobject->xmlrpcpath = $type.'/'.$plugin.'/'.$dataobject->filename.'/'.$method;
$dataobject->static = false;
require_once($path . '/' . $dataobject->filename);
$functionreflect = null; // slightly different ways to get this depending on whether it's a class method or a function
if (!empty($dataobject->classname)) {
if (!class_exists($dataobject->classname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
$key = $dataobject->filename . '|' . $dataobject->classname;
if (!array_key_exists($key, $cachedclasses)) { // look to see if we've already got a reflection object
try {
$cachedclasses[$key] = Zend_Server_Reflection::reflectClass($dataobject->classname);
} catch (Zend_Server_Reflection_Exception $e) { // catch these and rethrow them to something more helpful
throw new moodle_exception('installreflectionclasserror', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname, 'error' => $e->getMessage()));
}
}
$r =& $cachedclasses[$key];
if (!$r->hasMethod($dataobject->functionname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
// stupid workaround for zend not having a getMethod($name) function
$ms = $r->getMethods();
foreach ($ms as $m) {
if ($m->getName() == $dataobject->functionname) {
$functionreflect = $m;
break;
}
}
$dataobject->static = (int)$functionreflect->isStatic();
//.........这里部分代码省略.........
开发者ID:jtibbetts,项目名称:moodle,代码行数:101,代码来源:upgradelib.php
示例7: setClass
/**
* Register a class with the server
*
* @param string $class
* @param string $namespace Ignored
* @param mixed $argv Ignored
* @return Zend_Json_Server
*/
public function setClass($class, $namespace = '', $argv = null)
{
$argv = null;
if (3 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 3);
}
// require_once 'Zend/Server/Reflection.php';
$reflection = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
foreach ($reflection->getMethods() as $method) {
$definition = $this->_buildSignature($method, $class);
$this->_addMethodServiceMap($definition);
}
return $this;
}
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:23,代码来源:Server.php
示例8: setClass
/**
* Register a class with the server
*
* @param string $class
* @param string $namespace Ignored
* @param mixed $argv Ignored
* @return Zend_Json_Server
*/
public function setClass($class, $namespace = '', $argv = null)
{
require_once 'Zend/Server/Reflection.php';
$reflection = Zend_Server_Reflection::reflectClass($class);
foreach ($reflection->getMethods() as $method) {
$this->_methods[$method->getName()] = $method;
$this->_addMethodServiceMap($method);
}
return $this;
}
开发者ID:knjy24,项目名称:FrontAccounting,代码行数:18,代码来源:Server.php
示例9: setClass
/**
* Attach class methods as XMLRPC method handlers
*
* $class may be either a class name or an object. Reflection is done on the
* class or object to determine the available public methods, and each is
* attached to the server as an available method; if a $namespace has been
* provided, that namespace is used to prefix the XMLRPC method names.
*
* Any additional arguments beyond $namespace will be passed to a method at
* invocation.
*
* @param string|object $class
* @param string $namespace Optional
* @param mixed $argv Optional arguments to pass to methods
* @return void
* @throws Zend_XmlRpc_Server_Exception on invalid input
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)) {
if (!class_exists($class)) {
throw new Zend_XmlRpc_Server_Exception('Invalid method class', 610);
}
}
$argv = null;
if (3 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 3);
}
$this->_methods[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
$this->_buildDispatchTable();
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:32,代码来源:Server.php
示例10: array
/**
* Generate web service description array from the phpdoc for a given class
* @param string $file the class file
* @param string $class the class name
* @return array description
*
*
-------
Example
-------
* Docnlock: @ subparam string $params:searches->search - the string to search
* $params is considered as the first element, searches the second, and search the terminal
* Except the terminal element, all other will be generated as an array
* => left element are generated as an associative array.
* If the following character is ':' so the right element is a key named 'multiple:element_name'
* If the following character is '->' so the right element will be named 'element_name'
* Rule: If a key is named 'multiple:xxx' other key must be 'multiple:yyy'
Docblock of mock_function
---------------------------
@ param array|struct $params
@ subparam string $params:searches->search - the string to search
@ subparam string $params:searches->search2 optional - optional string to search
@ subparam string $params:searches->search3 - the string to search
@ subparam string $params:airport->planes:plane->company->employees:employee->name - name of a employee of a company of a plane of an airport
@ return array users
@ subreturn integer $users:user->id
@ subreturn integer $users:user->auth
Generated description array
---------------------------
description["mock_function"]=>
array(3) {
["params"]=>
array(2) {
["multiple:searches"]=>
array(2) {
["search"]=>
string(6) "string"
["search3"]=>
string(6) "string"
}
["multiple:airport"]=>
array(1) {
["planes"]=>
array(1) {
["multiple:plane"]=>
array(1) {
["company"]=>
array(1) {
["employees"]=>
array(1) {
["multiple:employee"]=>
array(1) {
["name"]=>
string(6) "string"
}
}
}
}
}
}
}
["optional"]=>
array(1) {
["multiple:searches"]=>
array(1) {
["search2"]=>
string(6) "string"
}
}
["return"]=>
array(1) {
["multiple:user"]=>
array(13) {
["id"]=>
string(7) "integer"
["auth"]=>
string(7) "integer"
}
}
*/
public static function generate_webservice_description($file, $class)
{
require_once $file;
require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();
$reflection = Zend_Server_Reflection::reflectClass($class);
$description = array();
foreach ($reflection->getMethods() as $method) {
$docBlock = $method->getDocComment();
//retrieve the return and add it into the description if not array|object
preg_match_all('/@return\\s+(\\w+)\\s+((?:\\$)?\\w+)/', $docBlock, $returnmatches);
//retrieve the subparam and subreturn
preg_match_all('/\\s*\\*\\s*@(subparam|subreturn)\\s+(\\w+)\\s+(\\$\\w+(?::\\w+|->\\w+)+)((?:\\s+(?:optional|required|multiple))*)/', $docBlock, $matches);
/// process every @subparam and @subreturn line of the docblock
for ($i = 0; $i < sizeof($matches[1]); $i++) {
/// identify the description type of the docblock line: is it params, optional or return (first key of a description method array)
switch ($matches[1][$i]) {
case "subparam":
//.........这里部分代码省略.........
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:lib.php
示例11: setClass
/**
* Attach class methods as XMLRPC method handlers
*
* $class may be either a class name or an object. Reflection is done on the
* class or object to determine the available public methods, and each is
* attached to the server as an available method; if a $namespace has been
* provided, that namespace is used to prefix the XMLRPC method names.
*
* Any additional arguments beyond $namespace will be passed to a method at
* invocation.
*
* @param string|object $class
* @param string $namespace Optional
* @param mixed $argv Optional arguments to pass to methods
* @return void
* @throws Zend_XmlRpc_Server_Exception on invalid input
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)) {
//require_once 'Zend/XmlRpc/Server/Exception.php';
throw new Zend_XmlRpc_Server_Exception('Invalid method class', 610);
}
$args = null;
if (2 < func_num_args()) {
$args = func_get_args();
$args = array_slice($args, 2);
}
$dispatchable = Zend_Server_Reflection::reflectClass($class, $args, $namespace);
foreach ($dispatchable->getMethods() as $reflection) {
$this->_buildSignature($reflection, $class);
}
}
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:33,代码来源:Server.php
示例12: addFunction
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $namespace Function namespace - Not Used
* @return Zend_Soap_AutoDiscover
*/
public function addFunction($function, $namespace = '')
{
static $port;
static $operation;
static $binding;
if (!is_array($function)) {
$function = (array) $function;
}
$uri = $this->getUri();
if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
$parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
$name = $parts[0];
$wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
} else {
$wsdl = $this->_wsdl;
}
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
return $this;
}
开发者ID:conectapb,项目名称:sysagroweb,代码行数:36,代码来源:AutoDiscover.php
示例13: addFunction
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $namespace Function namespace - Not Used
*/
public function addFunction($function, $namespace = '')
{
static $port;
static $operation;
static $binding;
if (!is_array($function)) {
$function = (array) $function;
}
$uri = $this->getUri();
if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
$parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
$name = $parts[0];
$wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
} else {
$wsdl = $this->_wsdl;
}
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
foreach ($method->getPrototypes() as $prototype) {
$args = array();
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = $wsdl->getType($param->getType());
}
$message = $wsdl->addMessage($method->getName() . 'Request', $args);
$desc = $method->getDescription();
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($message, $desc);
}
if ($prototype->getReturnType() != "void") {
if ($this->_responseMessageReturnNameCompability === true) {
$returnName = "return";
} else {
$returnName = $method->getName() . 'Return';
}
$message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType())));
}
/* <wsdl:portType>'s */
$portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' . $method->getName() . 'Request', 'tns:' . $method->getName() . 'Response');
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($portOperation, $desc);
}
/* </wsdl:portType>'s */
/* <wsdl:binding>'s */
$operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
$wsdl->addSoapOperation($operation, $uri->getUri() . '#' . $method->getName());
/* </wsdl:binding>'s */
$this->_functions[] = $method->getName();
// We will only add one prototype
break;
}
}
$this->_wsdl = $wsdl;
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:63,代码来源:AutoDiscover.php
示例14: addFunction
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $namespace Function namespace - Not Used
*/
public function addFunction($function, $namespace = '')
{
static $port;
static $operation;
static $binding;
if (!is_array($function)) {
$function = (array) $function;
}
$uri = Zend_Uri::factory('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
$parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
$name = $parts[0];
$wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_extractComplexTypes);
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
$wsdl->addSoapBinding($binding, 'rpc');
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
} else {
$wsdl = $this->_wsdl;
}
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
foreach ($method->getPrototypes() as $prototype) {
$args = array();
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = $wsdl->getType($param->getType());
}
$message = $wsdl->addMessage($method->getName() . 'Request', $args);
$desc = $method->getDescription();
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($message, $desc);
}
if ($prototype->getReturnType() != "void") {
$message = $wsdl->addMessage($method->getName() . 'Response', array($method->getName() . 'Return' => $wsdl->getType($prototype->getReturnType())));
}
/* <wsdl:portType>'s */
$portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' . $method->getName() . 'Request', 'tns:' . $method->getName() . 'Response');
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($portOperation, $desc);
}
/* </wsdl:portType>'s */
/* <wsdl:binding>'s */
$operation = $wsdl->addBindingOperation($binding, $method->getName(), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"));
$wsdl->addSoapOperation($binding, $uri->getUri() . '#' . $method->getName());
/* </wsdl:binding>'s */
$this->_functions[] = $method->getName();
// We will only add one prototype
break;
}
}
$this->_wsdl = $wsdl;
}
开发者ID:lortnus,项目名称:zf1,代码行数:58,代码来源:AutoDiscover.php
示例15: addFunction
/**
* Implement Zend_Server_Interface::addFunction()
*
* @param string $function Function Name
* @param string $namespace Function namespace (unused)
*/
public function addFunction($function, $namespace = '')
{
if (!is_array($function)) {
$function = (array) $function;
}
foreach ($function as $func) {
if (is_callable($func) && !in_array($func, self::$magic_methods)) {
$this->_functions[$func] = $this->_reflection->reflectFunction($func);
} else {
throw new Zend_Rest_Server_Exception("Invalid Method Added to Service.");
}
}
}
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:19,代码来源:Server.php
示例16: addFunction
/**
* Implement Zend_Server_Interface::addFunction()
*
* @param string $function Function Name
* @param string $namespace Function namespace (unused)
*/
public function addFunction($function, $namespace = '')
{
if (!is_array($function)) {
$function = (array) $function;
}
foreach ($function as $func) {
if (is_callable($func) && !in_array($func, self::$magicMethods)) {
$this->_functions[$func] = $this->_reflection->reflectFunction($func);
} else {
require_once PHP_LIBRARY_PATH . 'Zend/Rest/Server/Exception.php';
throw new Zend_Rest_Server_Exception("Invalid Method Added to Service.");
}
}
}
开发者ID:netixx,项目名称:Stock,代码行数:20,代码来源:Server.php
注:本文中的Zend_Server_Reflection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论