コード例 #1
0
ファイル: AutoDiscover.php プロジェクト: alab1001101/zf2
 /**
  * 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 WSDL\WSDL) {
         $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
         $name = $parts[0];
         $wsdl = new WSDL\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;
 }
コード例 #2
0
ファイル: Server.php プロジェクト: rexmac/zf2
 /**
  * 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);
     }
     $reflection = Reflection::reflectClass($class, $argv, $namespace);
     foreach ($reflection->getMethods() as $method) {
         $definition = $this->_buildSignature($method, $class);
         $this->_addMethodServiceMap($definition);
     }
     return $this;
 }
コード例 #3
0
ファイル: ReflectionTest.php プロジェクト: rexmac/zf2
 public function testReflectFunctionThrowsExceptionOnInvalidParam()
 {
     $this->setExpectedException('Zend\\Server\\Reflection\\Exception\\InvalidArgumentException', 'Invalid function');
     $reflection = Reflection\Reflection::reflectFunction(false);
 }
コード例 #4
0
ファイル: Server.php プロジェクト: niallmccrudden/zf2
    /**
     * 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)) {
            throw new Server\Exception\InvalidArgumentException('Invalid method class', 610);
        }

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

        $dispatchable = Reflection\Reflection::reflectClass($class, $argv, $namespace);
        foreach ($dispatchable->getMethods() as $reflection) {
            $this->_buildSignature($reflection, $class);
        }
    }
コード例 #5
0
 /**
  * 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)) {
         if (!$this->_loadClass($serviceClass)) {
             return $this->_returnError('Invalid service name; class does not exist');
         }
     }
     $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\Reflection::reflectClass($serviceClass);
     $this->_addService($r, $this->_ops);
     $serv->appendChild($this->_types);
     $serv->appendChild($this->_ops);
     $this->_xml->appendChild($serv);
     return $this->_xml->saveXML();
 }
コード例 #6
0
ファイル: Server.php プロジェクト: rkeplin/zf2
    /**
     * 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)) {
            throw new Exception\InvalidArgumentException('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)) {
                throw new Exception\InvalidArgumentException('Unable to attach function');
            }
            $this->_methods[] = Reflection\Reflection::reflectFunction($func, $argv, $namespace);
        }

        $this->_buildDispatchTable();
        return $this;
    }
コード例 #7
0
ファイル: ReflectionTest.php プロジェクト: bradley-holt/zf2
 /**
  * reflectFunction() test; test namespaces
  */
 public function testReflectFunction2()
 {
     $reflection = Reflection\Reflection::reflectFunction('ZendTest\\Server\\reflectionTestFunction', false, 'zsr');
     $this->assertEquals('zsr', $reflection->getNamespace());
 }