Ejemplo n.º 1
0
 public function deleteDocument($databaseName, &$doc)
 {
     if (!$doc instanceof Document && !$doc instanceof \stdClass && !is_array($doc)) {
         throw new RuntimeException("doc is not a instance of (Document or stdClass or Array)");
     }
     if (!$doc instanceof Document) {
         $doc = new Document($doc, $this, $databaseName);
     }
     $parameters = array('rev' => $doc->_rev);
     $uriOptions = array('database' => $databaseName, 'docId' => $doc->_id, 'parameters' => array_merge($parameters, $this->getRequestParameters()));
     $uri = $this->buildUri($uriOptions);
     $request = $this->getRequest();
     $request->setUri($uri);
     $request->setMethod($request::METHOD_DELETE);
     $response = $this->sendRequest();
     if (!is_string($response) && isset($response->error)) {
         throw $this->createExceptionInstance($response, $uriOptions, array('uri' => $uri));
     }
     $doc->setDeleted();
     return $response;
 }