Esempio n. 1
0
 /**
  * @param Node $node
  * @param Repository $repository
  * @param callable $loadCallback
  * @return mixed
  */
 function fromNode(Node $node, Repository $repository, \Closure $loadCallback)
 {
     $class = $node->getProperty('class');
     $meta = $repository->fromClass($class);
     $proxyClass = $meta->getProxyClass();
     $proxy = $this->createProxy($meta);
     $proxy->__setMeta($meta);
     $proxy->__setNode($node);
     $proxy->__setLoadCallback($loadCallback);
     $pk = $meta->getPrimaryKey();
     $pk->setValue($proxy, $node->getId());
     $proxy->__addHydrated($pk->getName());
     foreach ($meta->getProperties() as $property) {
         $name = $property->getName();
         if (null !== ($value = $node->getProperty($name))) {
             $property->setValue($proxy, $value);
             $proxy->__addHydrated($name);
         }
     }
     foreach ($meta->getManyToManyRelations() as $property) {
         if ($property->isWriteOnly()) {
             $proxy->__addHydrated($property->getName());
         }
     }
     return $proxy;
 }
Esempio n. 2
0
 /**
  * @group neo4j-v2
  */
 function testObtainLabels()
 {
     $repo = new MetaRepository();
     $meta = $repo->fromClass('HireVoice\\Neo4j\\Tests\\Entity\\City');
     $names = $meta->getLabels();
     $this->assertEquals(array('Location', 'City'), $names);
 }
Esempio n. 3
0
 /**
  * @param $entity
  * @return Meta\Entity
  */
 private function getMeta($entity)
 {
     return $this->metaRepository->fromClass(get_class($entity));
 }