src/Controller/ModelCollector.php
private function internalCollectChildrenOf(ModelInterface $model, $providerName = '', $recursive = false)
    {
        if ('' === $providerName) {
            $providerName = $model->getProviderName();
        }

        $ids = ($model->getProviderName() === $providerName) ? [$model->getId()] : [];

        // Check all data providers for children of the given element.
        $childIds = [];
        foreach ($this->relationships->getChildConditions($model->getProviderName()) as $condition) {
            $provider = $this->environment->getDataProvider($condition->getDestinationName());
            $config   = $provider->getEmptyConfig();
            $config->setFilter($condition->getFilter($model));

            foreach ($provider->fetchAll($config) as $child) {
                /** @var ModelInterface $child */

                if (!$recursive && $child->getProviderName() === $providerName) {
                    $ids[] = $child->getId();
                }

                if (false === $recursive) {
                    continue;
                }
                // Head into recursion.
                $childIds[] = $this->collectChildrenOf($child, $providerName);
            }
        }

        return \array_merge($ids, ...$childIds);
    }
private function internalCollectChildrenOf(ModelInterface $model, $providerName = '', $recursive = false)
    {
        if ('' === $providerName) {
            $providerName = $model->getProviderName();
        }

        $ids = ($model->getProviderName() === $providerName) ? [$model->getId()] : [];

        // Check all data providers for children of the given element.
        $childIds = [];
        foreach ($this->relationships->getChildConditions($model->getProviderName()) as $condition) {
            $provider = $this->environment->getDataProvider($condition->getDestinationName());
            $config   = $provider->getEmptyConfig();
            $config->setFilter($condition->getFilter($model));

            foreach ($provider->fetchAll($config) as $child) {
                /** @var ModelInterface $child */

                if (!$recursive && $child->getProviderName() === $providerName) {
                    $ids[] = $child->getId();
                }

                if (false === $recursive) {
                    continue;
                }
                // Head into recursion.
                $childIds[] = $this->collectChildrenOf($child, $providerName);
            }
        }

        return \array_merge($ids, ...$childIds);
    }
private function internalCollectChildrenOf ( ModelInterface $ model , $ providerName = '' , $ recursive = false ) { if ( '' === $ providerName ) { $ providerName = $ model -> getProviderName ( ) ; } $ ids = ( $ model -> getProviderName ( ) === $ providerName ) ? [ $ model -> getId ( ) ] : [ ] ; // Check all data providers for children of the given element. $ childIds = [ ] ; foreach ( $ this -> relationships -> getChildConditions ( $ model -> getProviderName ( ) ) as $ condition ) { $ provider = $ this -> environment -> getDataProvider ( $ condition -> getDestinationName ( ) ) ; $ config = $ provider -> getEmptyConfig ( ) ; $ config -> setFilter ( $ condition -> getFilter ( $ model ) ) ; foreach ( $ provider -> fetchAll ( $ config ) as $ child ) { /** @var ModelInterface $child */ if ( ! $ recursive && $ child -> getProviderName ( ) === $ providerName ) { $ ids [ ] = $ child -> getId ( ) ; } if ( false === $ recursive ) { continue ; } // Head into recursion. $ childIds [ ] = $ this -> collectChildrenOf ( $ child , $ providerName ) ; } } return \ array_merge ( $ ids , ... $ childIds ) ; }
Scan for children of a given model.

This method is ready for mixed hierarchy and will return all children and grandchildren for the given table
(or originating table of the model, if no provider name has been given) for all levels and parent child
conditions.

@param ModelInterface $model        The model to assemble children from.
@param string         $providerName The name of the data provider to fetch children from.
@param bool           $recursive    Determine for recursive sampling. For models with included child models.

@return array
Scan for children of a given model .