Пример #1
0
 /** 
  * method appender 
  *
  * @param XML_RPC2_Server_Method Method to append to methods
  */
 protected function addMethod(XML_RPC2_Server_Method $method)
 {
     $this->methods[$method->getName()] = $method;
 }
Пример #2
0
 /**
  * XML_RPC2_Server_Callhandler_Class Constructor. Creates a new call handler exporting the given object methods
  *
  * Before using this constructor, take a look at XML_RPC2_Server::create. The factory
  * method is usually a quicker way of instantiating the server and its call handler.
  *
  * @see XML_RPC2_Server::create()
  * @param object The Target object. Calls will be made on this instance
  * @param string Default prefix to prepend to all exported methods (defaults to '')
  */
 public function __construct($instance, $defaultPrefix)
 {
     $this->_instance = $instance;
     $reflection = new ReflectionClass(get_class($instance));
     foreach ($reflection->getMethods() as $method) {
         if (!$method->isStatic() && $method->isPublic() && !$method->isConstructor()) {
             $candidate = new XML_RPC2_Server_Method($method, $defaultPrefix);
             if (!$candidate->isHidden()) {
                 $this->addMethod($candidate);
             }
         }
     }
 }
Пример #3
0
 /** 
  * Check if method matches provided call signature 
  * 
  * Compare the provided call signature with this methods' signature and
  * return true iff they match.
  *
  * @param  string Signature to compare method name
  * @param  array  Array of parameter values for method call.
  * @return boolean True if call matches signature, false otherwise
  */
 public function matchesSignature($methodName, $callParams)
 {
     if ($methodName != $this->_name) {
         return false;
     }
     if (count($callParams) < $this->_numberOfRequiredParameters) {
         return false;
     }
     if (count($callParams) > $this->_parameters) {
         return false;
     }
     $paramIndex = 0;
     foreach ($this->_parameters as $param) {
         $paramIndex++;
         if ($paramIndex <= $this->_numberOfRequiredParameters) {
             // the parameter is not optional
             $callParamType = XML_RPC2_Server_Method::_limitPHPType(gettype($callParams[$paramIndex - 1]));
             if (!($param['type'] == 'mixed') and $param['type'] != $callParamType) {
                 return false;
             }
         }
     }
     return true;
 }