src/Cache/DatabaseTreeCache.php
public function getChildRecords(string $table, array $ids = [], $maxLevels = null, string $key = 'id', array $children = [], int $level = 0): array
    {
        if (null === ($tree = $this->getTreeCache($table, $key))) {
            return $this->database->getChildRecords($ids, $table);
        }

        foreach ($ids as $i => $id) {
            if (!isset($tree[$id]) || !\is_array($tree[$id])) {
                continue;
            }

            $children = array_merge($children, $tree[$id]);

            if (1 === $maxLevels) {
                continue;
            }

            if ($maxLevels > 0 && $level > $maxLevels) {
                return [];
            }

            if (!empty($nested = self::getChildRecords($table, $tree[$id], $maxLevels, $key, $children, ++$level))) {
                $children = $nested;
            } else {
                $depth = 0;
            }
        }

        return $children;
    }
public function getChildRecords(string $table, array $ids = [], $maxLevels = null, string $key = 'id', array $children = [], int $level = 0): array
    {
        if (null === ($tree = $this->getTreeCache($table, $key))) {
            return $this->database->getChildRecords($ids, $table);
        }

        foreach ($ids as $i => $id) {
            if (!isset($tree[$id]) || !\is_array($tree[$id])) {
                continue;
            }

            $children = array_merge($children, $tree[$id]);

            if (1 === $maxLevels) {
                continue;
            }

            if ($maxLevels > 0 && $level > $maxLevels) {
                return [];
            }

            if (!empty($nested = self::getChildRecords($table, $tree[$id], $maxLevels, $key, $children, ++$level))) {
                $children = $nested;
            } else {
                $depth = 0;
            }
        }

        return $children;
    }
public function getChildRecords ( string $ table , array $ ids = [ ] , $ maxLevels = null , string $ key = 'id' , array $ children = [ ] , int $ level = 0 ) : array { if ( null === ( $ tree = $ this -> getTreeCache ( $ table , $ key ) ) ) { return $ this -> database -> getChildRecords ( $ ids , $ table ) ; } foreach ( $ ids as $ i => $ id ) { if ( ! isset ( $ tree [ $ id ] ) || ! \ is_array ( $ tree [ $ id ] ) ) { continue ; } $ children = array_merge ( $ children , $ tree [ $ id ] ) ; if ( 1 === $ maxLevels ) { continue ; } if ( $ maxLevels > 0 && $ level > $ maxLevels ) { return [ ] ; } if ( ! empty ( $ nested = self :: getChildRecords ( $ table , $ tree [ $ id ] , $ maxLevels , $ key , $ children , ++ $ level ) ) ) { $ children = $ nested ; } else { $ depth = 0 ; } } return $ children ; }
Get all child records for given parent entities.

@param string $table     The database table
@param array  $ids       The parent entity ids
@param int    $maxLevels The max stop level
@param string Custom index key (default: primary key from model)
@param array $children Internal children return array
@param int   $level    Internal depth attribute

@return array An array containing all children for given parent entities
Get all child records for given parent entities .