public function getRelationships($direction = Relationship::DIRECTION_BOTH, $types = NULL) { $uri = $this->getUri() . '/relationships'; switch ($direction) { case Relationship::DIRECTION_IN: $uri .= '/in'; break; case Relationship::DIRECTION_OUT: $uri .= '/out'; break; default: $uri .= '/all'; } if ($types) { if (is_array($types)) { $types = implode("&", $types); } $uri .= '/' . $types; } list($response, $http_code) = HTTPUtil::jsonGetRequest($uri); $relationships = array(); foreach ($response as $result) { $relationships[] = Relationship::inflateFromResponse($this->_neo_db, $result); } return $relationships; }
/** * get relationship by uri * * @throws \Neo4j\Exception\NotFoundException * @throws \Neo4j\Exception\HttpException * @param string $uri * @return Neo4j\Relationship */ public function getRelationshipByUri($uri) { list($response, $http_code) = Request::get($uri); if ($http_code == 404) { throw new \Neo4j\Exception\NotFoundException(); } if ($http_code != 200) { throw new \Neo4j\Exception\HttpException("http code: " . $http_code . ", response: " . print_r($response, true)); } return Relationship::inflateFromResponse($this, $response); }
/** * get relationships of node and filtered by directions and types * * @param string $direction * @param array|null $types * @return array */ public function getRelationships($direction = Database::DIRECTION_BOTH, $types = NULL) { $uri = $this->getUri() . '/relationships'; switch ($direction) { case Database::DIRECTION_INCOMING: $uri .= '/' . Database::DIRECTION_INCOMING; break; case Database::DIRECTION_OUTGOING: $uri .= '/' . Database::DIRECTION_OUTGOING; break; default: $uri .= '/' . Database::DIRECTION_BOTH; } if ($types) { if (is_array($types)) { $types = implode("&", $types); } $uri .= '/' . $types; } list($response, $http_code) = Request::get($uri); $relationships = array(); foreach ($response as $result) { $relationships[] = Relationship::inflateFromResponse($this->_db, $result); } return $relationships; }