ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
Instance.php
Go to the documentation of this file.
1 <?php
2 
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4 
5 // LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6 
40 // }}}
41 
42 // dependencies {{{
43 require_once 'XML/RPC2/Exception.php';
44 require_once 'XML/RPC2/Server/Method.php';
45 require_once 'XML/RPC2/Server/CallHandler.php';
46 // }}}
47 
89 {
90 
91  // {{{ properties
92 
98  private $_instance;
99 
100  // }}}
101  // {{{ constructor
102 
113  public function __construct($instance, $defaultPrefix)
114  {
115  $this->_instance = $instance;
116  $reflection = new ReflectionClass(get_class($instance));
117  foreach ($reflection->getMethods() as $method) {
118  if (!$method->isStatic() && $method->isPublic() && !$method->isConstructor())
119  {
120  $candidate = new XML_RPC2_Server_Method($method, $defaultPrefix);
121  if (!$candidate->isHidden()) $this->addMethod($candidate);
122  }
123  }
124  }
125 
126  // }}}
127  // {{{ __call()
128 
136  public function __call($methodName, $parameters)
137  {
138  if (!array_key_exists($methodName, $this->getMethods())) {
139  throw new XML_RPC2_UnknownMethodException("Method $methodName is not exported by this server");
140  }
141  return call_user_func_array(array($this->_instance, $this->getMethod($methodName)->getInternalMethod()), $parameters);
142  }
143 
144  // }}}
145 
146 }
147 
148 ?>