src/Cache/DatabaseTreeCache.php
public function generateCacheTree(string $table, array $ids = [], string $key = 'id', array $config = [], $return = []): array
    {
        foreach ($ids as $id) {
            if (null === ($children = $this->modelUtil->findModelInstancesBy($table, ['pid = ?'], $id, $config['options']))) {
                $return[$id] = [];

                continue;
            }

            while ($children->next()) {
                $return[$children->pid][$children->{$key}] = $children->{$key};
                $return = $this->generateCacheTree($table, [$children->{$key}], $key, $config, $return);
            }
        }

        return $return;
    }
public function generateCacheTree(string $table, array $ids = [], string $key = 'id', array $config = [], $return = []): array
    {
        foreach ($ids as $id) {
            if (null === ($children = $this->modelUtil->findModelInstancesBy($table, ['pid = ?'], $id, $config['options']))) {
                $return[$id] = [];

                continue;
            }

            while ($children->next()) {
                $return[$children->pid][$children->{$key}] = $children->{$key};
                $return = $this->generateCacheTree($table, [$children->{$key}], $key, $config, $return);
            }
        }

        return $return;
    }
public function generateCacheTree ( string $ table , array $ ids = [ ] , string $ key = 'id' , array $ config = [ ] , $ return = [ ] ) : array { foreach ( $ ids as $ id ) { if ( null === ( $ children = $ this -> modelUtil -> findModelInstancesBy ( $ table , [ 'pid = ?' ] , $ id , $ config [ 'options' ] ) ) ) { $ return [ $ id ] = [ ] ; continue ; } while ( $ children -> next ( ) ) { $ return [ $ children -> pid ] [ $ children -> { $ key } ] = $ children -> { $ key } ; $ return = $ this -> generateCacheTree ( $ table , [ $ children -> { $ key } ] , $ key , $ config , $ return ) ; } } return $ return ; }
Generate the flat cache tree.

@param string $table  The database table
@param string $key    Custom index key (default: primary key from model)
@param array  $ids    Root identifiers (parent ids)
@param array  $config Tree config
@param array  $return Internal return array

@return array The flat cache tree
Generate the flat cache tree .