Ejemplo n.º 1
0
 /**
  * Find the handler method for a REST request
  * 
  * @param string $method The method (GET/POST/...)
  * @param string $path The REST server path
  * @return array The handler method and the path or NULL, if not found
  */
 private function GetRestMethod($method, $path)
 {
     if (substr($path, strlen($path) - 1) != '/') {
         $path .= '/';
     }
     // Find a REST method
     PhpWsdl::Debug('Find REST method "' . $method . '" at "' . $path . '"');
     $i = -1;
     $mLen = sizeof($this->Server->Methods);
     while (++$i < $mLen) {
         $m = $this->Server->Methods[$i];
         if (is_null($m->Settings)) {
             continue;
         }
         if (!isset($m->Settings['rest'])) {
             continue;
         }
         if (!isset($m->Settings['rest'][$method])) {
             continue;
         }
         $rest = $m->Settings['rest'][$method];
         $j = -1;
         $rLen = sizeof($rest);
         while (++$j < $rLen) {
             $call = $rest[$j]['path'];
             $param = null;
             if (strpos($call, ':') > -1) {
                 list($call, $param) = explode(':', $call, 2);
             }
             if (substr($call, strlen($call) - 1) != '/') {
                 $call .= '/';
             }
             if (!is_null($param) && substr($path, 0, strlen($call)) == $call || $path == $call) {
                 PhpWsdl::Debug('Method found at index #' . $i . ' with target "' . $rest[$j]['path'] . '"');
                 return array($m, $rest[$j]['path']);
             }
         }
     }
     // Find a method without REST declaration
     $temp = explode('/', $path);
     $res = $this->Server->GetMethod($temp[1]);
     return is_null($res) ? null : array($res, null);
 }