GraphAware\Neo4j\Client\HttpDriver\Session::rollbackTransaction PHP Method

rollbackTransaction() public method

public rollbackTransaction ( integer $transactionId )
$transactionId integer
    public function rollbackTransaction($transactionId)
    {
        $request = new Request('DELETE', sprintf('%s/db/data/transaction/%d', $this->uri, $transactionId));
        try {
            $this->httpClient->send($request);
        } catch (RequestException $e) {
            if ($e->hasResponse()) {
                $body = json_decode($e->getResponse()->getBody(), true);
                if (!isset($body['code'])) {
                    throw $e;
                }
                $msg = sprintf('Neo4j Exception with code "%s" and message "%s"', $body['errors'][0]['code'], $body['errors'][0]['message']);
                $exception = new Neo4jException($msg);
                $exception->setNeo4jStatusCode($body['errors'][0]['code']);
                throw $exception;
            }
            throw $e;
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     $this->assertNotClosed();
     $this->assertStarted();
     $this->session->rollbackTransaction($this->transactionId);
     $this->closed = true;
     $this->state = self::ROLLED_BACK;
     $this->session->transaction = null;
 }