src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
protected function parseParentChildConditions(ContainerInterface $container)
    {
        if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) {
            $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME);
        } else {
            $definition = new DefaultModelRelationshipDefinition();
        }

        // If mode is 5, we need to define tree view.
        if (5 === $this->getFromDca('list/sorting/mode')) {
            $rootProvider = $this->getRootProviderName($container);

            if (null === ($relationship = $definition->getRootCondition())) {
                $relationship = new RootCondition();
                $relationship
                    ->setSourceName($rootProvider);
                $definition->setRootCondition($relationship);

                $builder = FilterBuilder::fromArrayForRoot()->getFilter();
            } else {
                $builder = FilterBuilder::fromArrayForRoot($relationship->getFilterArray())->getFilter();
            }

            $relationship
                ->setSetters(
                    \array_merge_recursive(
                        [['property' => 'pid', 'value' => '0']]
                    ),
                    $relationship->getSetters()
                );

            $builder->andPropertyEquals('pid', '0');

            $relationship
                ->setFilterArray($builder->getAllAsArray());

            if (null === ($relationship = $definition->getChildCondition($rootProvider, $rootProvider))) {
                $relationship = new ParentChildCondition();
                $relationship
                    ->setSourceName($rootProvider)
                    ->setDestinationName($rootProvider);
                $definition->addChildCondition($relationship);

                $builder = FilterBuilder::fromArray()->getFilter();
            } else {
                $builder = FilterBuilder::fromArray($relationship->getFilterArray())->getFilter();
            }

            $relationship
                ->setSetters(
                    \array_merge_recursive(
                        [['to_field' => 'pid', 'from_field' => 'id']]
                    ),
                    $relationship->getSetters()
                );

            $builder->andRemotePropertyEquals('pid', 'id');
            $relationship
                ->setFilterArray($builder->getAllAsArray());

            $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition);
        }

        // If ptable defined and no root setter we need to add (Contao default id=>pid mapping).
        if (null !== $this->getFromDca('config/ptable')) {
            $rootProvider = $this->getRootProviderName($container);

            if (null === ($relationship = $definition->getRootCondition())) {
                $relationship = new RootCondition();
                $relationship
                    ->setSourceName($rootProvider);

                $definition->setRootCondition($relationship);
            }

            if (!$relationship->getSetters()) {
                $relationship
                    ->setSetters(
                        \array_merge_recursive(
                            [['property' => 'pid', 'value' => '0']]
                        ),
                        $relationship->getSetters()
                    );
            }

            $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition);
        }
    }
protected function parseParentChildConditions(ContainerInterface $container)
    {
        if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) {
            $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME);
        } else {
            $definition = new DefaultModelRelationshipDefinition();
        }

        // If mode is 5, we need to define tree view.
        if (5 === $this->getFromDca('list/sorting/mode')) {
            $rootProvider = $this->getRootProviderName($container);

            if (null === ($relationship = $definition->getRootCondition())) {
                $relationship = new RootCondition();
                $relationship
                    ->setSourceName($rootProvider);
                $definition->setRootCondition($relationship);

                $builder = FilterBuilder::fromArrayForRoot()->getFilter();
            } else {
                $builder = FilterBuilder::fromArrayForRoot($relationship->getFilterArray())->getFilter();
            }

            $relationship
                ->setSetters(
                    \array_merge_recursive(
                        [['property' => 'pid', 'value' => '0']]
                    ),
                    $relationship->getSetters()
                );

            $builder->andPropertyEquals('pid', '0');

            $relationship
                ->setFilterArray($builder->getAllAsArray());

            if (null === ($relationship = $definition->getChildCondition($rootProvider, $rootProvider))) {
                $relationship = new ParentChildCondition();
                $relationship
                    ->setSourceName($rootProvider)
                    ->setDestinationName($rootProvider);
                $definition->addChildCondition($relationship);

                $builder = FilterBuilder::fromArray()->getFilter();
            } else {
                $builder = FilterBuilder::fromArray($relationship->getFilterArray())->getFilter();
            }

            $relationship
                ->setSetters(
                    \array_merge_recursive(
                        [['to_field' => 'pid', 'from_field' => 'id']]
                    ),
                    $relationship->getSetters()
                );

            $builder->andRemotePropertyEquals('pid', 'id');
            $relationship
                ->setFilterArray($builder->getAllAsArray());

            $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition);
        }

        // If ptable defined and no root setter we need to add (Contao default id=>pid mapping).
        if (null !== $this->getFromDca('config/ptable')) {
            $rootProvider = $this->getRootProviderName($container);

            if (null === ($relationship = $definition->getRootCondition())) {
                $relationship = new RootCondition();
                $relationship
                    ->setSourceName($rootProvider);

                $definition->setRootCondition($relationship);
            }

            if (!$relationship->getSetters()) {
                $relationship
                    ->setSetters(
                        \array_merge_recursive(
                            [['property' => 'pid', 'value' => '0']]
                        ),
                        $relationship->getSetters()
                    );
            }

            $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition);
        }
    }
protected function parseParentChildConditions ( ContainerInterface $ container ) { if ( $ container -> hasDefinition ( ModelRelationshipDefinitionInterface :: NAME ) ) { $ definition = $ container -> getDefinition ( ModelRelationshipDefinitionInterface :: NAME ) ; } else { $ definition = new DefaultModelRelationshipDefinition ( ) ; } // If mode is 5, we need to define tree view. if ( 5 === $ this -> getFromDca ( 'list/sorting/mode' ) ) { $ rootProvider = $ this -> getRootProviderName ( $ container ) ; if ( null === ( $ relationship = $ definition -> getRootCondition ( ) ) ) { $ relationship = new RootCondition ( ) ; $ relationship -> setSourceName ( $ rootProvider ) ; $ definition -> setRootCondition ( $ relationship ) ; $ builder = FilterBuilder :: fromArrayForRoot ( ) -> getFilter ( ) ; } else { $ builder = FilterBuilder :: fromArrayForRoot ( $ relationship -> getFilterArray ( ) ) -> getFilter ( ) ; } $ relationship -> setSetters ( \ array_merge_recursive ( [ [ 'property' => 'pid' , 'value' => '0' ] ] ) , $ relationship -> getSetters ( ) ) ; $ builder -> andPropertyEquals ( 'pid' , '0' ) ; $ relationship -> setFilterArray ( $ builder -> getAllAsArray ( ) ) ; if ( null === ( $ relationship = $ definition -> getChildCondition ( $ rootProvider , $ rootProvider ) ) ) { $ relationship = new ParentChildCondition ( ) ; $ relationship -> setSourceName ( $ rootProvider ) -> setDestinationName ( $ rootProvider ) ; $ definition -> addChildCondition ( $ relationship ) ; $ builder = FilterBuilder :: fromArray ( ) -> getFilter ( ) ; } else { $ builder = FilterBuilder :: fromArray ( $ relationship -> getFilterArray ( ) ) -> getFilter ( ) ; } $ relationship -> setSetters ( \ array_merge_recursive ( [ [ 'to_field' => 'pid' , 'from_field' => 'id' ] ] ) , $ relationship -> getSetters ( ) ) ; $ builder -> andRemotePropertyEquals ( 'pid' , 'id' ) ; $ relationship -> setFilterArray ( $ builder -> getAllAsArray ( ) ) ; $ container -> setDefinition ( ModelRelationshipDefinitionInterface :: NAME , $ definition ) ; } // If ptable defined and no root setter we need to add (Contao default id=>pid mapping). if ( null !== $ this -> getFromDca ( 'config/ptable' ) ) { $ rootProvider = $ this -> getRootProviderName ( $ container ) ; if ( null === ( $ relationship = $ definition -> getRootCondition ( ) ) ) { $ relationship = new RootCondition ( ) ; $ relationship -> setSourceName ( $ rootProvider ) ; $ definition -> setRootCondition ( $ relationship ) ; } if ( ! $ relationship -> getSetters ( ) ) { $ relationship -> setSetters ( \ array_merge_recursive ( [ [ 'property' => 'pid' , 'value' => '0' ] ] ) , $ relationship -> getSetters ( ) ) ; } $ container -> setDefinition ( ModelRelationshipDefinitionInterface :: NAME , $ definition ) ; } }
This method parses the parent-child conditions.

@param ContainerInterface $container The container where the data shall be stored.

@return void
This method parses the parent - child conditions .