コード例 #1
0
 /**
  * Since it's difficult to determine if a GET request was a FETCH or
  * QUERY, this does the right thing (hopefully)
  *
  * @param  string $path
  * @param  array  $args
  * @return array  $response
  */
 public function query_or_fetch($path, $args = array())
 {
     $rsc = $this->parser->resource($path);
     // if not found, it shouldn't matter which we call
     if (!$rsc) {
         $rsc = new Rframe_StaticResource($this->parser);
         $rsc->code = Rframe::BAD_PATH;
         $rsc->message = "Invalid path: '{$path}'";
         return $rsc->query($args);
     }
     // more info about resource
     $uuid = $this->parser->uuid($path);
     $cls = get_class($rsc);
     $is_one = $rsc->get_rel_type($cls) == Rframe_Resource::ONE_TO_ONE;
     // determine if this is likely a query or fetch path
     if (!$is_one && $uuid || $is_one && !$uuid) {
         return $rsc->fetch($uuid, $args);
     } else {
         return $rsc->query($args);
     }
 }
コード例 #2
0
 /**
  * Public function to delete a resource
  *
  * @param string  $path
  * @return array $response
  */
 public function delete($path)
 {
     $rsc = $this->parser->resource($path);
     $found = $rsc;
     if (!$found) {
         $rsc = new Rframe_StaticResource($this->parser);
         $rsc->code = Rframe::BAD_PATH;
         $rsc->message = "Invalid path: '{$path}'";
     }
     $uuid = $this->parser->uuid($path);
     return $rsc->delete($uuid);
 }