/** * @param Response $response * * @return array */ private function getResponse(Response $response) { $result = $response->getBody()['results'][0]; $columns = $result['columns']; $rows = array_map(function (array $data) use($columns) { return $this->createRow($columns, $data['row']); }, $result['data']); return $rows; }
private function getResponse(ResponseInterface $httpResponse) { $response = new Response($httpResponse); if ($httpResponse->getBody()) { $resp = (string) $httpResponse->getBody(); $decoded = json_decode($resp, true); $response->setBody($decoded); } return $response; }
/** * @param mixed $response * * @return string|array|\Neoxygen\NeoClient\Formatter\Response * * @throws Neo4jException */ public function handleHttpResponse(Response $response) { $this->checkResponseErrors($response->getBody()); if ($this->autoFormatResponse) { $formatted = $this->formatResponse($response->getBody()); $response->setResult($formatted->getResult()); $response->setRows($formatted->geRows()); } return $response; }
/** * @param Response $response * * @return string|array|\Neoxygen\NeoClient\Formatter\Response * * @throws Neo4jException */ public function handleHttpResponse(Response $response) { if ($this->newFormatModeEnabled) { $newResponse = $this->newFormattingService->formatResponse($response->getRaw()); if ($newResponse->hasError()) { $error = $newResponse->getError(); throw new Neo4jException(sprintf($error->getCode(), $error->getMessage(), Neo4jException::fromCode($error->getCode()))); } return $newResponse; } $this->checkResponseErrors($response->getBody()); if ($this->autoFormatResponse) { $formatted = $this->formatResponse($response->getBody()); $response->setResult($formatted->getResult()); $response->setRows($formatted->geRows()); } return $response; }
/** * @param array $labels * @param string|null $conn * * @return Response * @deprecetad Will be removed in 4.0 */ public function listIndexes(array $labels = array(), $conn = null) { if (empty($labels)) { $labels = $this->getLabels($conn)->getBody(); } $indexes = []; foreach ($labels as $label) { $res = $this->listIndex($label, $conn); $indexs = $res->getBody(); $indexes[$label] = $indexs; } if (!isset($res)) { if ($this->newFormatModeEnabled) { $res = new \GraphAware\NeoClient\Formatter\Response(new PsrResponse(200)); } else { $res = new Response(new PsrResponse(200)); } } if ($res instanceof \GraphAware\NeoClient\Formatter\Response) { return new \GraphAware\NeoClient\Formatter\Response(new PsrResponse(200, [], json_encode($indexes))); } $response = new Response($res->getRaw()); $response->setBody($indexes); return $response; }
/** * @param array $labels * @param string|null $conn * * @return Response */ public function listIndexes(array $labels = array(), $conn = null) { if (empty($labels)) { $labels = $this->getLabels($conn)->getBody(); } $indexes = []; foreach ($labels as $label) { $indexs = $this->listIndex($label, $conn)->getBody(); $indexes[$label] = $indexs; } $response = new Response(); $response->setBody($indexes); return $response; }