Example #1
0
 /**
  * Gather the properties of a Node including its id.
  *
  * @param  \Everyman\Neo4j\Node   $node
  * @return array
  */
 public function getNodeAttributes(Node $node)
 {
     // Extract the properties of the node
     $attributes = $node->getProperties();
     // Add the node id to the attributes since \Everyman\Neo4j\Node
     // does not consider it to be a property, it is treated differently
     // and available through the getId() method.
     $attributes[$this->model->getKeyName()] = $node->getId();
     return $attributes;
 }
Example #2
0
 /**
  * Hydrate a Collection from an Neo4J Node
  *
  * @param \Everyman\Neo4j\Node $row a single row from result set to map.
  * @return Collection
  */
 protected function nodeToCollection(\EveryMan\Neo4j\Node $row)
 {
     // Or we map a single record to a Spider Record
     $collection = new Collection();
     foreach ($row->getProperties() as $key => $value) {
         $collection->add($key, $value);
     }
     //handle labels
     $labels = $row->getLabels();
     if (!empty($labels)) {
         $collection->add(['meta.label' => $labels[0]->getName(), 'label' => $labels[0]->getName()]);
     }
     $collection->add(['meta.id' => $row->getId(), 'id' => $row->getId()]);
     $collection->protect('meta');
     $collection->protect('id');
     $collection->protect('label');
     return $collection;
 }