Пример #1
0
 /**
  *  Create Edge
  *
  *  Request to create a new edge in the collection
  *
  * @param array/Edge  $data - Array of the data for Edge / Edge Object to create .
  * @param string  $collection - specify the collectionID to create the Edge into.
  * @param array  $param - Array of parameters to send to the database as a options for edge request.
  *
  * @return array/Edge $response/$data - Return a response array of the request/Edge object.
  */
 public function CreateEdge($data, $collection = NULL, $param = NULL)
 {
     $option = array();
     if (isset($param['createCollection'])) {
         $option['createCollection'] = $param['createCollection'];
     }
     if (isset($param['waitForSync'])) {
         $option['waitForSync'] = $param['waitForSync'];
     }
     if (isset($param['from'])) {
         $option['from'] = $param['from'];
     }
     if (isset($param['to'])) {
         $option['to'] = $param['to'];
     }
     if ($data instanceof Edge) {
         $jdata = $data->getData();
         $option['collection'] = $data->getCollectionID();
         $option['from'] = $data->getFrom();
         $option['to'] = $data->getTo();
         $response = $this->post('edge', $jdata, 'json', $option);
         if ($response->code == '201' or $response->code == '202' or $response->code == '200') {
             $data->setData($response);
             return $data;
         } else {
             return $response;
         }
     } else {
         $jdata = $data;
         if ($collection != NULL) {
             $option['collection'] = $collection;
             $response = $this->post('edge', $jdata, 'json', $option);
             return $response;
         } else {
             return array("error" => "Must set collection ID");
         }
     }
 }