Parse the root condition.

@param ModelRelationshipDefinitionInterface $definition The relationship definition.

@return void

@throws DcGeneralRuntimeException If no root data provider is defined.
431593
protected function parseParentChildConditions(
        ModelRelationshipDefinitionInterface $definition
    ) {
        if (null !== ($childConditions = $this->getFromDca('dca_config/childCondition'))) {
            foreach ((array) $childConditions as $childCondition) {
                /** @var ParentChildConditionInterface $relationship */
                $relationship = $definition->getChildCondition($childCondition['from'], $childCondition['to']);
                if (!$relationship instanceof ParentChildConditionInterface) {
                    $relationship = new ParentChildCondition();
                    $relationship
                        ->setSourceName($childCondition['from'])
                        ->setDestinationName($childCondition['to']);
                    $definition->addChildCondition($relationship);
                    $setter  = $childCondition['setOn'];
                    $inverse = $childCondition['inverse'];
                } else {
                    $setter  = \array_merge_recursive((array) $childCondition['setOn'], $relationship->getSetters());
                    $inverse = \array_merge_recursive(
                        (array) $childCondition['inverse'],
                        $relationship->getInverseFilterArray()
                    );
                }

                $relationship
                    ->setFilterArray(
                        FilterBuilder::fromArray($relationship->getFilterArray())
                            ->getFilter()
                            ->append(
                                FilterBuilder::fromArray((array) $childCondition['filter'])
                            )
                            ->getAllAsArray()
                    )
                    ->setSetters($setter)
                    ->setInverseFilterArray($inverse);
            }
        }
    }
1164483
public static function loadDefinition(DefinitionInterface $definition): Graph
    {
        $graph = new Graph($definition);

        foreach ($definition->processes() as $id => $def) {
            $graph->addNode($id, $def[Net::COMPONENT]);
        }

        foreach ($definition->initializers() as $initializer) {
            $graph->addInitial(
                $initializer[Net::DATA],
                $initializer[Net::CONNECTION_TARGET][Net::PROCESS],
                $initializer[Net::CONNECTION_TARGET][Net::PORT]
            );
        }

        foreach ($definition->connections() as $conn) {
            $graph->addEdge(
                $conn[Net::CONNECTION_SOURCE][Net::PROCESS],
                $conn[Net::CONNECTION_SOURCE][Net::PORT],
                $conn[Net::CONNECTION_TARGET][Net::PROCESS],
                $conn[Net::CONNECTION_TARGET][Net::PORT]
            );
        }

        return $graph;
    }
502901
private function visit(Vertex $definition)
    {
        $definition->state = Vertex::IN_PROGRESS;

        foreach ($definition->dependencyList as $dependency) {
            if ( ! isset($this->nodeList[$dependency])) {
                throw new \RuntimeException(sprintf(
                    'Fixture "%s" has a dependency of fixture "%s", but it not listed to be loaded.',
                    get_class($definition->value),
                    $dependency
                ));
            }

            $childDefinition = $this->nodeList[$dependency];

            // allow self referencing classes
            if ($definition === $childDefinition) {
                continue;
            }

            switch ($childDefinition->state) {
                case Vertex::VISITED:
                    break;
                case Vertex::IN_PROGRESS:
                    if ( ! $this->allowCyclicDependencies) {
                        throw new CircularReferenceException(
                            sprintf(
                                'Graph contains cyclic dependency between the classes "%s" and'
                                .' "%s". An example of this problem would be the following: '
                                .'Class C has class B as its dependency. Then, class B has class A has its dependency. '
                                .'Finally, class A has class C as its dependency.',
                                $definition->value->getName(),
                                $childDefinition->value->getName()
                            )
                        );
                    }
                    break;
                case Vertex::NOT_VISITED:
                    $this->visit($childDefinition);
            }
        }

        $definition->state = Vertex::VISITED;

        $this->sortedNodeList[] = $definition->value;
    }
192646
private function getDictionaryBuilder(DictionaryDefinition $definition): DictionaryBuilderInterface
    {
        if (!$this->dictionaryBuilders->has($typeName = $definition->getType())) {
            $typeName = 'default';
        }

        return $this->dictionaryBuilders->get($typeName);
    }
431898
public function setDefinition($id, Definition $definition)
    {
        if ($this->isCompiled()) {
            throw new BadMethodCallException('Adding definition to a compiled container is not allowed');
        }

        $id = $this->normalizeId($id);

        unset($this->aliasDefinitions[$id], $this->removedIds[$id]);

        return $this->definitions[$id] = $definition;
    }
791336
public function bind(InputDefinition $definition)
    {
        $hasCodeArgument = false;

        if ($definition->getArgumentCount() > 0) {
            $args    = $definition->getArguments();
            $lastArg = \array_pop($args);
            foreach ($args as $arg) {
                if ($arg instanceof CodeArgument) {
                    $msg = \sprintf('Unexpected CodeArgument before the final position: %s', $arg->getName());
                    throw new \InvalidArgumentException($msg);
                }
            }

            if ($lastArg instanceof CodeArgument) {
                $hasCodeArgument = true;
            }
        }

        $this->hasCodeArgument = $hasCodeArgument;

        return parent::bind($definition);
    }
1055237
public function validate($value, Constraint $constraint): void
    {
        if (!$constraint instanceof Enum) {
            throw new \RuntimeException(\sprintf('Object of class %s is not instance of %s', \get_class($constraint), Enum::class));
        }

        if (!$constraint->entity) {
            throw new ConstraintDefinitionException('Entity not specified.');
        }

        $constraint->choices = $constraint->entity::getValues();

        parent::validate($value, $constraint);
    }
1215645
protected function _getDefinitionResolver(DefinitionInterface $definition)
    {
        $definitionType = get_class($definition);

        if (! isset($this->_definitionResolvers[$definitionType])) {
            throw new NotFoundException(
                "No definition resolver was configured for definition " .
                "of type $definitionType"
            );
        }

        return $this->_definitionResolvers[$definitionType];
    }
73458
protected function setDefinition($id, Definition $definition)
    {
        $this->container->removeBindings($id);

        if ($this->isLoadingInstanceof) {
            if (!$definition instanceof ChildDefinition) {
                throw new InvalidArgumentException(sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_class($definition)));
            }
            $this->instanceof[$id] = $definition;
        } else {
            $this->container->setDefinition($id, $definition instanceof ChildDefinition ? $definition : $definition->setInstanceofConditionals($this->instanceof));
        }
    }
1191502
function defineRelationshipResolution(
  schema: GraphQLSchema,
  relationships: Relationship[],
  database: DatabaseInterface,
): void {
  relationships.forEach(relationship => {
    defineFieldResolve(
      schema,
      relationship.path[0].fromType,
      relationship.fieldName,
      database.generateRelationshipResolver(relationship),
    );
  });
}
249752
public function bind(Definition $definition) {
        $this->arguments = [];
        $this->options = [];
        $this->definition = $definition;

        $this->parse();
    }
854805
public function parseRulesDefinition($definition): RulesCollection
    {
        if (is_callable($definition)) {

            $definition = [$definition];

        }

        if (is_string($definition)) {

            $definition = array_map('trim', explode('|', $definition));

        }

        if (is_array($definition)) {

            $keys = array_keys($definition);

            return array_reduce($keys, function ($rules, $key) use ($definition) {

                $definition = $definition[$key];

                $rule = $this->parseRuleDefinition($key, $definition);

                return $rules->withRule($rule);

            }, new RulesCollection);

        }

        throw new InvalidRuleFormatException($definition);
    }
1203307
private function addRuleCondition(QueryBuilder $query, EntityDefinition $definition, Context $context): void
    {
        if ($definition->isBlacklistAware() && $context->getRuleIds()) {
            $wheres = [];

            $accessor = $this->getFieldAccessor('blacklistIds', $definition, $definition->getEntityName(), $context);

            foreach ($context->getRuleIds() as $ruleId) {
                if (!Uuid::isValid($ruleId)) {
                    throw new InvalidUuidException($ruleId);
                }
                $wheres[] = sprintf(
                    'JSON_CONTAINS(IFNULL(' . $accessor . ', JSON_ARRAY()), JSON_ARRAY(:%s))',
                    'contextRule' . $ruleId
                );
                $query->setParameter('contextRule' . $ruleId, $ruleId);
            }

            $query->andWhere(implode(' + ', $wheres) . ' = 0');
        }

        if (!$definition->isWhitelistAware()) {
            return;
        }

        $accessor = $this->getFieldAccessor('whitelistIds', $definition, $definition->getEntityName(), $context);

        $wheres = [];
        foreach ($context->getRuleIds() as $id) {
            if (!Uuid::isValid($id)) {
                throw new InvalidUuidException($id);
            }
            $wheres[] = sprintf(
                'JSON_CONTAINS(IFNULL(' . $accessor . ', JSON_ARRAY()), JSON_ARRAY(:%s))',
                'contextRule' . $id
            );
            $query->setParameter('contextRule' . $id, $id);
        }

        $conditions = [
            '(JSON_DEPTH(' . $accessor . ') is null)',
            '(JSON_DEPTH(' . $accessor . ') = 1)',
        ];

        if (!empty($wheres)) {
            $conditions[] = implode(' + ', $wheres) . ' >= 1';
        }

        $query->andWhere('(' . implode(' OR ', $conditions) . ')');
    }
194592
protected function createIdentifierCollectionRelationship($object, RelationshipDefinition $definition, MappingContext $context): IdentifierCollectionRelationship
    {
        $relationship = new IdentifierCollectionRelationship();
        $collection   = $object->{$definition->getGetter()}();
        $dataLimit    = $definition->getDataLimit();

        if ($dataLimit > 0) {
            $collection = new \LimitIterator($collection, 0, $dataLimit);
        }

        $mapper = $context->getMapper();

        foreach ($collection as $relatedObject)
        {
            $resource = $mapper->toResourceIdentifier($relatedObject);

            $relationship->addIdentifier($resource);
        }

        return $relationship;
    }
209373
private function checkRelationInformation()
    {
        if ($this->getInspector()->getSchemaOid($this->schema) === null) {
            throw new GeneratorException(sprintf("Schema '%s' not found.", $this->schema));
        }

        $table_oid = $this->getInspector()->getTableOid($this->schema, $this->relation);

        if ($table_oid === null) {
            throw new GeneratorException(
                sprintf(
                    "Relation '%s' could not be found in schema '%s'.",
                    $this->relation,
                    $this->schema
                )
            );
        }

        return $table_oid;
    }
169573
@Override
	public void onRelationshipInstantiation() {

		try {

			if (dbRelationship != null) {

				Node startNode = dbRelationship.getStartNode();
				Node endNode   = dbRelationship.getEndNode();

				if ((startNode != null) && (endNode != null) && startNode.hasProperty(GraphObject.id.dbName()) && endNode.hasProperty(GraphObject.id.dbName())) {

					cachedStartNodeId = (String) startNode.getProperty(GraphObject.id.dbName());
					cachedEndNodeId   = (String) endNode.getProperty(GraphObject.id.dbName());

				}

			}

		} catch (Throwable t) {
		}
	}
118856
protected function resolveObjectRealInterfaceExtensions(ClassAwareDefinitionInterface $definition): void
    {
        $class = $definition->getClass();

        if (class_exists($class)) {
            $refClass = new \ReflectionClass($definition->getClass());
            if ($interfaces = $refClass->getInterfaceNames()) {
                foreach ($interfaces as $interface) {
                    $bundleNamespace = ClassUtils::relatedBundleNamespace($interface);
                    if (preg_match('/(\w+)Interface?$/', $interface, $matches)) {
                        $extensionClass = ClassUtils::applyNamingConvention($bundleNamespace, 'Extension', null, $matches[1].'Extension');
                        if (class_exists($extensionClass)) {
                            if ($definition instanceof HasExtensionsInterface) {
                                $definition->addExtension($extensionClass);
                            }
                        }
                    }
                }
            }
        }
    }