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

flush() public method

public flush ( Pipeline $pipeline ) : GraphAware\Common\Result\ResultCollection
$pipeline Pipeline
return GraphAware\Common\Result\ResultCollection
    public function flush(Pipeline $pipeline)
    {
        $request = $this->prepareRequest($pipeline);
        try {
            $response = $this->httpClient->send($request);
            $data = json_decode((string) $response->getBody(), true);
            if (!empty($data['errors'])) {
                $msg = sprintf('Neo4j Exception with code "%s" and message "%s"', $data['errors'][0]['code'], $data['errors'][0]['message']);
                $exception = new Neo4jException($msg);
                $exception->setNeo4jStatusCode($data['errors'][0]['code']);
                throw $exception;
            }
            $results = $this->responseFormatter->format(json_decode($response->getBody(), true), $pipeline->statements());
            return $results;
        } 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

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     return $this->session->flush($this);
 }