Exemplo n.º 1
0
 /**
  * Loads a relation using a proxy.
  *
  * Loads a relation using a proxy, and stores it in the appropriate places in the entity manager.
  *
  * @param \Everyman\Neo4J\Relationship $relation The relation to load.
  * @return mixed The entity itself.
  */
 public function loadRelation($relation)
 {
     //If the node isn't already loaded
     if (!isset($this->relationProxyCache[$relation->getId()])) {
         //Create a proxy entity
         $em = $this;
         $entity = $this->proxyFactory->fromRelation($relation, $this->metaRepository, function ($node) use($em) {
             return $em->loadNode($node);
         });
         $this->relationProxyCache[$relation->getId()] = $entity;
         $this->everymanRelationCache[$this->getHash($entity)] = $relation;
     }
     return $this->relationProxyCache[$relation->getId()];
 }
Exemplo n.º 2
0
 /**
  * Set a given relationship on this relation.
  *
  * @param \Everyman\Neo4j\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());
 }
Exemplo n.º 3
0
 public function wrap(Neo4j\Relationship $client_edge)
 {
     return new Edge($this, $client_edge->getId(), $client_edge);
 }