Beispiel #1
0
 private function _OptionsAll()
 {
     // 1.  Check if the method exists.
     if ($this->_ComponentMethodExists($this->_Component, 'Options')) {
         // Override Options
         $c = $this->_Component;
         $instance = $this->GetSys('Components')->{$c};
         $return = call_user_func_array(array($instance, 'Options'), $this->_Parameters);
         $this->Format($return);
         exit;
     }
     $return = array();
     $return['interface'] = strtolower($this->_Component);
     $return['objects'] = array();
     $class = $this->_Component;
     $reflect = new ReflectionClass($this->GetSys('Components')->{$class});
     $methods = $reflect->getMethods();
     $className = $reflect->GetName();
     foreach ($methods as $m => $method) {
         // Skip if we're looking at an inherited method.
         if ($method->GetDeclaringClass()->getName() != $className) {
             continue;
         }
         // Only match REST request methods.
         if (!preg_match("/^(Get|Post|Put|Delete)(.*)/", $method->getName(), $matches)) {
             continue;
         }
         $methodType = strtolower($matches[1]);
         $object = strtolower($matches[2]);
         $return['objects'][$object]['methods'][$methodType] = array();
         $parameters = $method->getParameters();
         foreach ($parameters as $p => $parameter) {
             $name = strtolower($parameter->getName());
             $return['objects'][$object]['methods'][$methodType]['params'][] = array();
             $pointer = count($return['objects'][$object]['methods'][$methodType]['params']) - 1;
             $return['objects'][$object]['methods'][$methodType]['params'][$pointer]['name'] = $name;
             if ($parameter->isDefaultValueAvailable()) {
                 $return['objects'][$object]['methods'][$methodType]['params'][$pointer]['required'] = '0';
                 $return['objects'][$object]['methods'][$methodType]['params'][$pointer]['default'] = $parameter->getDefaultValue();
             } else {
                 $return['objects'][$object]['methods'][$methodType]['params'][$pointer]['required'] = '1';
             }
         }
     }
     $this->Format($return);
     exit;
 }