Example #1
0
 /**
  * Set a given relationship on this relation.
  *
  * @param \\Orientdb\Relationship $relation
  */
 public function setRelation(Relationship $relation, $debug = false)
 {
     // Set the relation object.
     $this->relation = $relation;
     // Replace the attributes with those brought from the given relation.
     $this->attributes = $relation->getProperties();
     //$this->setAttribute($this->primaryKey, $relation->getId());
     // Set the start and end nodes.
     $this->start = $relation->getStartNode();
     $this->end = $relation->getEndNode();
     // Instantiate and fill out the related model.
     $relatedNode = $this->isDirectionOut() ? $this->end : $this->start;
     $attributes = array_merge(['id' => $relatedNode->getId()], $relatedNode->getProperties());
     // This is an existing relationship.
     $exists = true;
     $this->related = $this->related->newFromBuilder($attributes, $exists);
     $this->related->setConnection($this->related->getConnection());
 }