Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/webservice/amf/introspector.php
Go to the documentation of this file.
00001 <?php
00036 class MethodDescriptor {
00037 
00038     private $methods;
00039     private $classes;
00040 
00041         static public $classnametointrospect;
00042     
00043     
00044     public function __construct() {
00045         $this->setup();
00046     }
00047 
00048     private function setup() {
00049         global $CFG;
00050         if (!empty($this->nothing)) {
00051             return; // we've already tried, no classes.
00052         }
00053         if (!empty($this->classes)) { // we've already done it successfully.
00054             return;
00055         }
00056         /*if (empty($CFG->amf_introspection)) {
00057             throw new Exception(get_string('amfintrospectiondisabled', 'local'));
00058         }*/
00059         
00060         //just one class here, possibility for expansion in future
00061         $classes = array(MethodDescriptor::$classnametointrospect);
00062 
00063         $hugestructure = array();
00064 
00065         foreach ($classes as $c) {
00066             $r = new ReflectionClass($c);
00067 
00068             if (!$methods = $r->getMethods()) {
00069                 continue;
00070             }
00071             $this->classes[] = $c;
00072             $hugestructure[$c] = array('docs' => $r->getDocComment(), 'methods' => array());
00073             foreach ($methods as $method) {
00074                 if (!$method->isPublic()) {
00075                     continue;
00076                 }
00077                 $params = array();
00078                 foreach ($method->getParameters() as $param) {
00079                     $params[] = array('name' => $param->getName(), 'required' => !$param->isOptional());
00080                 }
00081                 $hugestructure[$c]['methods'][$method->getName()] = array(
00082                     'docs' => $method->getDocComment(),
00083                     'params' => $params,
00084                 );
00085             }
00086         }
00087         $this->methods = $hugestructure;
00088         if (empty($this->classes)) {
00089             $this->nothing = true;
00090         }
00091     }
00092 
00093     public function getMethods() {
00094         $this->setup();
00095         return $this->methods;
00096     }
00097 
00098     public function getClasses() {
00099         $this->setup();
00100         return $this->classes;
00101     }
00102     
00103     public function isConnected() {
00104         return true;
00105     }
00106 }
00107 
 All Data Structures Namespaces Files Functions Variables Enumerations