|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00032 class Zend_Server_Method_Definition 00033 { 00037 protected $_callback; 00038 00042 protected $_invokeArguments = array(); 00043 00047 protected $_methodHelp = ''; 00048 00052 protected $_name; 00053 00057 protected $_object; 00058 00062 protected $_prototypes = array(); 00063 00070 public function __construct($options = null) 00071 { 00072 if ((null !== $options) && is_array($options)) { 00073 $this->setOptions($options); 00074 } 00075 } 00076 00083 public function setOptions(array $options) 00084 { 00085 foreach ($options as $key => $value) { 00086 $method = 'set' . ucfirst($key); 00087 if (method_exists($this, $method)) { 00088 $this->$method($value); 00089 } 00090 } 00091 return $this; 00092 } 00093 00100 public function setName($name) 00101 { 00102 $this->_name = (string) $name; 00103 return $this; 00104 } 00105 00111 public function getName() 00112 { 00113 return $this->_name; 00114 } 00115 00122 public function setCallback($callback) 00123 { 00124 if (is_array($callback)) { 00125 require_once 'Zend/Server/Method/Callback.php'; 00126 $callback = new Zend_Server_Method_Callback($callback); 00127 } elseif (!$callback instanceof Zend_Server_Method_Callback) { 00128 require_once 'Zend/Server/Exception.php'; 00129 throw new Zend_Server_Exception('Invalid method callback provided'); 00130 } 00131 $this->_callback = $callback; 00132 return $this; 00133 } 00134 00140 public function getCallback() 00141 { 00142 return $this->_callback; 00143 } 00144 00151 public function addPrototype($prototype) 00152 { 00153 if (is_array($prototype)) { 00154 require_once 'Zend/Server/Method/Prototype.php'; 00155 $prototype = new Zend_Server_Method_Prototype($prototype); 00156 } elseif (!$prototype instanceof Zend_Server_Method_Prototype) { 00157 require_once 'Zend/Server/Exception.php'; 00158 throw new Zend_Server_Exception('Invalid method prototype provided'); 00159 } 00160 $this->_prototypes[] = $prototype; 00161 return $this; 00162 } 00163 00170 public function addPrototypes(array $prototypes) 00171 { 00172 foreach ($prototypes as $prototype) { 00173 $this->addPrototype($prototype); 00174 } 00175 return $this; 00176 } 00177 00184 public function setPrototypes(array $prototypes) 00185 { 00186 $this->_prototypes = array(); 00187 $this->addPrototypes($prototypes); 00188 return $this; 00189 } 00190 00196 public function getPrototypes() 00197 { 00198 return $this->_prototypes; 00199 } 00200 00207 public function setMethodHelp($methodHelp) 00208 { 00209 $this->_methodHelp = (string) $methodHelp; 00210 return $this; 00211 } 00212 00218 public function getMethodHelp() 00219 { 00220 return $this->_methodHelp; 00221 } 00222 00229 public function setObject($object) 00230 { 00231 if (!is_object($object) && (null !== $object)) { 00232 require_once 'Zend/Server/Exception.php'; 00233 throw new Zend_Server_Exception('Invalid object passed to ' . __CLASS__ . '::' . __METHOD__); 00234 } 00235 $this->_object = $object; 00236 return $this; 00237 } 00238 00244 public function getObject() 00245 { 00246 return $this->_object; 00247 } 00248 00255 public function setInvokeArguments(array $invokeArguments) 00256 { 00257 $this->_invokeArguments = $invokeArguments; 00258 return $this; 00259 } 00260 00266 public function getInvokeArguments() 00267 { 00268 return $this->_invokeArguments; 00269 } 00270 00276 public function toArray() 00277 { 00278 $prototypes = $this->getPrototypes(); 00279 $signatures = array(); 00280 foreach ($prototypes as $prototype) { 00281 $signatures[] = $prototype->toArray(); 00282 } 00283 00284 return array( 00285 'name' => $this->getName(), 00286 'callback' => $this->getCallback()->toArray(), 00287 'prototypes' => $signatures, 00288 'methodHelp' => $this->getMethodHelp(), 00289 'invokeArguments' => $this->getInvokeArguments(), 00290 'object' => $this->getObject(), 00291 ); 00292 } 00293 }