Exemplo n.º 1
0
 /**
  * Find the relationships for the given node property
  *
  * @param NodeMetadata $metadata
  * @param Property $property
  * @param array $info
  *
  * @return array
  */
 protected function getNodeRelationships(NodeMetadata $metadata, Property $property, array $info)
 {
     $relationships = [];
     $relClass = $this->map->getClass($property->getOption('relationship'));
     foreach ($this->entities as $entity) {
         if (!$entity instanceof $relClass) {
             continue;
         }
         $relInfo = $this->entities->getInfo($entity);
         if (in_array($info['realId'], [$relInfo['startNode'], $relInfo['endNode']], true)) {
             $relationships[] = $entity;
         }
     }
     if (!empty($relationships)) {
         return $relationships;
     }
     $idProp = $metadata->getId()->getProperty();
     $qb = new QueryBuilder();
     $qb->addExpr($qb->expr()->matchNode('n', $metadata->getClass(), [$idProp => $info['properties'][$idProp]])->relatedTo($qb->expr()->matchRelationship('r', $relClass)))->toReturn('r');
     return $this->uow->execute($qb->getQuery());
 }
Exemplo n.º 2
0
 /**
  * Configure a node related config
  *
  * @param NodeMetadata $meta
  * @param array $config
  *
  * @return void
  */
 protected function configureNode(NodeMetadata $meta, array $config)
 {
     foreach ($config['labels'] as $label) {
         $meta->addLabel($label);
     }
 }