public function filesAutoComplete(Request $request)
    {
        $term = $request->query->get('term', '.*');
        $dir = Path::getDirectory($term);
        $term = Path::getFilename($term);
        $term = preg_quote($term);

        $extensions = implode('|', explode(',', $request->query->get('ext', '.*')));
        $regex = sprintf('/.*(%s).*\.(%s)$/', $term, $extensions);

        $files = $this->filesystem()
            ->find()
            ->in('files://' . $dir)
            ->name($regex)
        ;

        $result = [];
        /** @var \Bolt\Filesystem\Handler\File $file */
        foreach ($files as $file) {
            $result[] = $file->toJs();
        }

        return $this->json($result);
    }
public function filesAutoComplete(Request $request)
    {
        $term = $request->query->get('term', '.*');
        $dir = Path::getDirectory($term);
        $term = Path::getFilename($term);
        $term = preg_quote($term);

        $extensions = implode('|', explode(',', $request->query->get('ext', '.*')));
        $regex = sprintf('/.*(%s).*\.(%s)$/', $term, $extensions);

        $files = $this->filesystem()
            ->find()
            ->in('files://' . $dir)
            ->name($regex)
        ;

        $result = [];
        /** @var \Bolt\Filesystem\Handler\File $file */
        foreach ($files as $file) {
            $result[] = $file->toJs();
        }

        return $this->json($result);
    }
public function filesAutoComplete ( Request $ request ) { $ term = $ request -> query -> get ( 'term' , '.*' ) ; $ dir = Path :: getDirectory ( $ term ) ; $ term = Path :: getFilename ( $ term ) ; $ term = preg_quote ( $ term ) ; $ extensions = implode ( '|' , explode ( ',' , $ request -> query -> get ( 'ext' , '.*' ) ) ) ; $ regex = sprintf ( '/.*(%s).*\.(%s)$/' , $ term , $ extensions ) ; $ files = $ this -> filesystem ( ) -> find ( ) -> in ( 'files://' . $ dir ) -> name ( $ regex ) ; $ result = [ ] ; /** @var \Bolt\Filesystem\Handler\File $file */ foreach ( $ files as $ file ) { $ result [ ] = $ file -> toJs ( ) ; } return $ this -> json ( $ result ) ; }
Return autocomplete data for a file name.

@param Request $request

@return \Symfony\Component\HttpFoundation\JsonResponse
Return autocomplete data for a file name .