Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public static function fromConfig(CollectionInterface $config) : TypeInterface
 {
     $type = new self();
     if (!$config->hasKey('inner')) {
         throw TypeDeclarationException::missingField('inner');
     }
     if (self::identifiers()->contains($config->get('inner'))) {
         throw new RecursiveTypeDeclarationException();
     }
     $type->inner = $config->get('_types')->build($config->get('inner'), $config->unset('inner')->unset('_types'));
     if ($config->hasKey('nullable')) {
         $type->nullable = true;
     }
     return $type;
 }
Beispiel #2
0
 /**
  * Add the cypher clause to build the relationship and the node corresponding
  * to a child of the aggregate
  *
  * @param ValueObject $meta
  * @param Str $nodeName
  * @param CollectionInterface $data
  * @param Query $query
  *
  * @return Query
  */
 private function createAggregateChild(ValueObject $meta, Str $nodeName, CollectionInterface $data, Query $query) : Query
 {
     $relationshipName = $nodeName->append('_')->append($meta->relationship()->property());
     $endNodeName = $relationshipName->append('_')->append($meta->relationship()->childProperty());
     $endNodeProperties = $this->buildProperties($meta->properties(), $endNodeParamKey = $endNodeName->append('_props'));
     $relationshipProperties = $this->buildProperties($meta->relationship()->properties(), $relationshipParamKey = $relationshipName->append('_props'));
     return $query->create((string) $nodeName)->linkedTo((string) $endNodeName, $meta->labels()->toPrimitive())->withProperties($endNodeProperties->toPrimitive())->withParameters([(string) $endNodeParamKey => $data->get($meta->relationship()->childProperty())->toPrimitive()])->through((string) $meta->relationship()->type(), (string) $relationshipName, DBALRelationship::LEFT)->withProperties($relationshipProperties->toPrimitive())->withParameters([(string) $relationshipParamKey => $data->unset($meta->relationship()->childProperty())->toPrimitive()]);
 }