app/Http/Controllers/AutocompleteController.php
public function folder(ServerRequestInterface $request, Tree $tree, Filesystem $filesystem): ResponseInterface
    {
        $query = $request->get('query', '');

        $prefix = $tree->getPreference('MEDIA_DIRECTORY', '');

        $media_filesystem = new Filesystem(new ChrootAdapter($filesystem, $prefix));

        $contents = new Collection($media_filesystem->listContents('', true));

        $folders = $contents
            ->filter(static function (array $object) use ($query): bool {
                return $object['type'] === 'dir' && Str::contains($object['path'], $query);
            })
            ->map(static function (array $object): array {
                return ['value' => $object['path']];
            });

        return response($folders);
    }
public function folder(ServerRequestInterface $request, Tree $tree, Filesystem $filesystem): ResponseInterface
    {
        $query = $request->get('query', '');

        $prefix = $tree->getPreference('MEDIA_DIRECTORY', '');

        $media_filesystem = new Filesystem(new ChrootAdapter($filesystem, $prefix));

        $contents = new Collection($media_filesystem->listContents('', true));

        $folders = $contents
            ->filter(static function (array $object) use ($query): bool {
                return $object['type'] === 'dir' && Str::contains($object['path'], $query);
            })
            ->map(static function (array $object): array {
                return ['value' => $object['path']];
            });

        return response($folders);
    }
public function folder ( ServerRequestInterface $ request , Tree $ tree , Filesystem $ filesystem ) : ResponseInterface { $ query = $ request -> get ( 'query' , '' ) ; $ prefix = $ tree -> getPreference ( 'MEDIA_DIRECTORY' , '' ) ; $ media_filesystem = new Filesystem ( new ChrootAdapter ( $ filesystem , $ prefix ) ) ; $ contents = new Collection ( $ media_filesystem -> listContents ( '' , true ) ) ; $ folders = $ contents -> filter ( static function ( array $ object ) use ( $ query ) : bool { return $ object [ 'type' ] === 'dir' && Str :: contains ( $ object [ 'path' ] , $ query ) ; } ) -> map ( static function ( array $ object ) : array { return [ 'value' => $ object [ 'path' ] ] ; } ) ; return response ( $ folders ) ; }
Autocomplete for media folders.

@param ServerRequestInterface $request
@param Tree                   $tree
@param Filesystem             $filesystem

@return ResponseInterface
Autocomplete for media folders .