private function addChildren($path, $file, $tree = [])
    {
        $child = null;

        if (count($path) > 0) {
            $child = array_shift($path);
            $tree = $this->addChildren($path, $file, $tree);
        }

        $newTree = [];
        if ($child) {
            $newTree['folders'][$child] = $tree;
        } else {
            $newTree['files'][] = $file;
        }

        return $newTree;
    }
private function addChildren($path, $file, $tree = [])
    {
        $child = null;

        if (count($path) > 0) {
            $child = array_shift($path);
            $tree = $this->addChildren($path, $file, $tree);
        }

        $newTree = [];
        if ($child) {
            $newTree['folders'][$child] = $tree;
        } else {
            $newTree['files'][] = $file;
        }

        return $newTree;
    }
private function addChildren ( $ path , $ file , $ tree = [ ] ) { $ child = null ; if ( count ( $ path ) > 0 ) { $ child = array_shift ( $ path ) ; $ tree = $ this -> addChildren ( $ path , $ file , $ tree ) ; } $ newTree = [ ] ; if ( $ child ) { $ newTree [ 'folders' ] [ $ child ] = $ tree ; } else { $ newTree [ 'files' ] [ ] = $ file ; } return $ newTree ; }
Recursive method that adds the children of tree menu.

@param string $path The path
@param mixed  $file The file
@param array  $tree The tree

@return array
Recursive method that adds the children of tree menu .