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


PHP Zend_Server_Reflection::reflectFunction方法代码示例

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


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

示例1: addFunction

 /**
  * Attach a function or callback to the server
  * 
  * @param  string|array $function Valid PHP callback
  * @param  string $namespace  Ignored
  * @return Zend_Json_Server
  */
 public function addFunction($function, $namespace = '')
 {
     if (!is_string($function) && (!is_array($function) || 2 > count($function))) {
         require_once 'Zend/Json/Server/Exception.php';
         throw new Zend_Json_Server_Exception('Unable to attach function; invalid');
     }
     if (!is_callable($function)) {
         require_once 'Zend/Json/Server/Exception.php';
         throw new Zend_Json_Server_Exception('Unable to attach function; does not exist');
     }
     require_once 'Zend/Server/Reflection.php';
     if (is_string($function)) {
         $method = Zend_Server_Reflection::reflectFunction($function);
     } else {
         $class = array_shift($function);
         $action = array_shift($function);
         $reflection = Zend_Server_Reflection::reflectClass($class);
         $methods = $reflection->getMethods();
         $found = false;
         foreach ($methods as $method) {
             if ($action == $method->getName()) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $this->fault('Method not found', -32601);
             return $this;
         }
     }
     $this->_methods[$method->getName()] = $method;
     $this->_addMethodServiceMap($method);
     return $this;
 }
开发者ID:knjy24,项目名称:FrontAccounting,代码行数:41,代码来源:Server.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: addFunction

    /**
     * Attach a callback as an XMLRPC method
     *
     * Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name
     * with $namespace, if provided. Reflection is done on the callback's
     * docblock to create the methodHelp for the XMLRPC method.
     *
     * 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 void
     * @throws Zend_XmlRpc_Server_Exception
     */
    public function addFunction($function, $namespace = '')
    {
        if (!is_string($function) && !is_array($function)) {
            require_once 'Zend/XmlRpc/Server/Exception.php';
            throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
        }

        $argv = null;
        if (2 < func_num_args()) {
            $argv = func_get_args();
            $argv = array_slice($argv, 2);
        }

        $function = (array) $function;
        foreach ($function as $func) {
            if (!is_string($func) || !function_exists($func)) {
                require_once 'Zend/XmlRpc/Server/Exception.php';
                throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
            }
            $reflection = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
            $this->_buildSignature($reflection);
        }
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:39,代码来源:Server.php

示例8: 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

示例9: 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

示例10: upgrade_plugin_mnet_functions


//.........这里部分代码省略.........

            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();
            } else {
                if (!function_exists($dataobject->functionname)) {
                    throw new moodle_exception('installnosuchfunction', 'mnet', '', (object)array('method' => $dataobject->functionname, 'file' => $dataobject->filename));
                }
                try {
                    $functionreflect = Zend_Server_Reflection::reflectFunction($dataobject->functionname);
                } catch (Zend_Server_Reflection_Exception $e) { // catch these and rethrow them to something more helpful
                    throw new moodle_exception('installreflectionfunctionerror', 'mnet', '', (object)array('method' => $dataobject->functionname, '' => $dataobject->filename, 'error' => $e->getMessage()));
                }
            }
            $dataobject->profile =  serialize(admin_mnet_method_profile($functionreflect));
            $dataobject->help = $functionreflect->getDescription();

            if ($record_exists = $DB->get_record('mnet_rpc', array('xmlrpcpath'=>$dataobject->xmlrpcpath))) {
                $dataobject->id      = $record_exists->id;
                $dataobject->enabled = $record_exists->enabled;
                $DB->update_record('mnet_rpc', $dataobject);
            } else {
                $dataobject->id = $DB->insert_record('mnet_rpc', $dataobject, true);
            }

            // TODO this API versioning must be reworked, here the recently processed method
            // sets the service API which may not be correct
            foreach ($publishmethodservices[$dataobject->functionname] as $service) {
                if ($serviceobj = $DB->get_record('mnet_service', array('name'=>$service['servicename']))) {
                    $serviceobj->apiversion = $service['apiversion'];
                    $DB->update_record('mnet_service', $serviceobj);
                } else {
                    $serviceobj = new stdClass();
                    $serviceobj->name        = $service['servicename'];
                    $serviceobj->description = empty($service['description']) ? '' : $service['description'];
                    $serviceobj->apiversion  = $service['apiversion'];
                    $serviceobj->offer       = 1;
                    $serviceobj->id          = $DB->insert_record('mnet_service', $serviceobj);
                }
                $servicecache[$service['servicename']] = $serviceobj;
                if (!$DB->record_exists('mnet_service2rpc', array('rpcid'=>$dataobject->id, 'serviceid'=>$serviceobj->id))) {
                    $obj = new stdClass();
开发者ID:jtibbetts,项目名称:moodle,代码行数:67,代码来源:upgradelib.php

示例11: addFunction

 /**
  * Attach a callback as an XMLRPC method
  *
  * Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name 
  * with $namespace, if provided. Reflection is done on the callback's 
  * docblock to create the methodHelp for the XMLRPC method.
  *
  * 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 void
  * @throws Zend_XmlRpc_Server_Exception
  */
 public function addFunction($function, $namespace = '')
 {
     if (!is_string($function) && !is_array($function)) {
         throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
     }
     $argv = null;
     if (2 < func_num_args()) {
         $argv = func_get_args();
         $argv = array_slice($argv, 2);
     }
     $function = (array) $function;
     foreach ($function as $func) {
         if (!is_string($func) || !function_exists($func)) {
             throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
         }
         $this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
     }
     $this->_buildDispatchTable();
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:35,代码来源:Server.php

示例12: addFunction

 /**
  * Attach a function or callback to the server
  *
  * @param  string|array $function Valid PHP callback
  * @param  string $namespace  Ignored
  * @return Zend_Json_Server
  */
 public function addFunction($function, $namespace = '')
 {
     if (!is_string($function) && (!is_array($function) || 2 > count($function))) {
         //$1 'Zend/Json/Server/Exception.php';
         throw new Zend_Json_Server_Exception('Unable to attach function; invalid');
     }
     if (!is_callable($function)) {
         //$1 'Zend/Json/Server/Exception.php';
         throw new Zend_Json_Server_Exception('Unable to attach function; does not exist');
     }
     $argv = null;
     if (2 < func_num_args()) {
         $argv = func_get_args();
         $argv = array_slice($argv, 2);
     }
     //$1 'Zend/Server/Reflection.php';
     if (is_string($function)) {
         $method = Zend_Server_Reflection::reflectFunction($function, $argv, $namespace);
     } else {
         $class = array_shift($function);
         $action = array_shift($function);
         $reflection = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
         $methods = $reflection->getMethods();
         $found = false;
         foreach ($methods as $method) {
             if ($action == $method->getName()) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $this->fault('Method not found', -32601);
             return $this;
         }
     }
     $definition = $this->_buildSignature($method);
     $this->_addMethodServiceMap($definition);
     return $this;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:46,代码来源:Server.php


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