public function save() { $start_node = $this->start_node; $end_node = $this->end_node; if (!$start_node) { throw new \LogicException('Cannot save an edge with no start node.'); } if (!$end_node) { throw new \LogicException('Cannot save an edge with no end node.'); } if (!$start_node->hasId()) { $start_node->save(); } if (!$end_node->hasId()) { $end_node->save(); } // Make an edge if this edge is new. if (!$this->hasId($this->id)) { $client_edge = $this->client->makeRelationship(); $client_edge->setType($this->schema->getName()); $this->client_object = $client_edge; } else { if (!$this->client_object) { $this->fetch(); } } $client_edge = $this->client_object; $client_edge->setStartNode($start_node->getClientObject()); $client_edge->setEndNode($end_node->getClientObject()); parent::save(); }
public function save() { // Make a node if this node is new. if ($is_new = !$this->hasId()) { $this->client_object = $this->client->makeNode(); } parent::save(); // Labels can only be added after the node is saved. if ($is_new) { $this->client_object->addLabels(array($this->client->makeLabel($this->schema->getName()))); } // Index the node. $this->index(); }