public function manage(Request $request, $namespace, $path)
    {
        $fullPath = "$namespace://$path";
        $directory = $this->filesystem()->getDir($fullPath);
        $listing = new Listing($directory);
        $showHidden = $this->isAllowed('files:hidden');

        if (!$listing->isAuthorized()) {
            $this->flashes()->error(Trans::__('general.phrase.access-denied-permissions-view-file-directory', ['%s' => $fullPath]));

            return $this->redirectToRoute('dashboard');
        }
        try {
            $directories = $listing->getDirectories($showHidden);
            $files = $listing->getFiles($showHidden);
        } catch (IOException $e) {
            $this->flashes()->error(Trans::__('page.file-management.message.folder-not-found', ['%s' => $path]));

            return $this->redirectToRoute('dashboard');
        }

        $form = null;
        if (!$request->query->has('CKEditor') && $this->isAllowed('files:uploads')) {
            // Define the "Upload here" form.
            $options = ['accept' => '.' . implode(',.', $this->getOption('general/accept_file_types'))];
            $form = $this->createFormBuilder(FileUploadType::class, null, $options)
                ->getForm()
            ;

            // Handle the upload.
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $this->handleUpload($form, $directory);

                return $this->redirectToRoute('files', ['path' => $path, 'namespace' => $namespace]);
            }
            if ($form->isSubmitted() && !$form->isValid()) {
                $this->flashes()->error(Trans::__('general.phrase.file-upload-failed'));
            }
        }

        // Select the correct template to render this. If we've got 'CKEditor' in the title, it's a dialog
        // from CKEditor to insert a file.
        $template = $request->query->has('CKEditor') ? '@bolt/files_ck/files_ck.twig' : '@bolt/files/files.twig';

        $context = [
            'directory'   => $directory,
            'directories' => $directories,
            'files'       => $files,
            'form'        => $form ? $form->createView() : false,
        ];

        return $this->render($template, $context);
    }
public function manage(Request $request, $namespace, $path)
    {
        $fullPath = "$namespace://$path";
        $directory = $this->filesystem()->getDir($fullPath);
        $listing = new Listing($directory);
        $showHidden = $this->isAllowed('files:hidden');

        if (!$listing->isAuthorized()) {
            $this->flashes()->error(Trans::__('general.phrase.access-denied-permissions-view-file-directory', ['%s' => $fullPath]));

            return $this->redirectToRoute('dashboard');
        }
        try {
            $directories = $listing->getDirectories($showHidden);
            $files = $listing->getFiles($showHidden);
        } catch (IOException $e) {
            $this->flashes()->error(Trans::__('page.file-management.message.folder-not-found', ['%s' => $path]));

            return $this->redirectToRoute('dashboard');
        }

        $form = null;
        if (!$request->query->has('CKEditor') && $this->isAllowed('files:uploads')) {
            // Define the "Upload here" form.
            $options = ['accept' => '.' . implode(',.', $this->getOption('general/accept_file_types'))];
            $form = $this->createFormBuilder(FileUploadType::class, null, $options)
                ->getForm()
            ;

            // Handle the upload.
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $this->handleUpload($form, $directory);

                return $this->redirectToRoute('files', ['path' => $path, 'namespace' => $namespace]);
            }
            if ($form->isSubmitted() && !$form->isValid()) {
                $this->flashes()->error(Trans::__('general.phrase.file-upload-failed'));
            }
        }

        // Select the correct template to render this. If we've got 'CKEditor' in the title, it's a dialog
        // from CKEditor to insert a file.
        $template = $request->query->has('CKEditor') ? '@bolt/files_ck/files_ck.twig' : '@bolt/files/files.twig';

        $context = [
            'directory'   => $directory,
            'directories' => $directories,
            'files'       => $files,
            'form'        => $form ? $form->createView() : false,
        ];

        return $this->render($template, $context);
    }
public function manage ( Request $ request , $ namespace , $ path ) { $ fullPath = "$namespace://$path" ; $ directory = $ this -> filesystem ( ) -> getDir ( $ fullPath ) ; $ listing = new Listing ( $ directory ) ; $ showHidden = $ this -> isAllowed ( 'files:hidden' ) ; if ( ! $ listing -> isAuthorized ( ) ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'general.phrase.access-denied-permissions-view-file-directory' , [ '%s' => $ fullPath ] ) ) ; return $ this -> redirectToRoute ( 'dashboard' ) ; } try { $ directories = $ listing -> getDirectories ( $ showHidden ) ; $ files = $ listing -> getFiles ( $ showHidden ) ; } catch ( IOException $ e ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'page.file-management.message.folder-not-found' , [ '%s' => $ path ] ) ) ; return $ this -> redirectToRoute ( 'dashboard' ) ; } $ form = null ; if ( ! $ request -> query -> has ( 'CKEditor' ) && $ this -> isAllowed ( 'files:uploads' ) ) { // Define the "Upload here" form. $ options = [ 'accept' => '.' . implode ( ',.' , $ this -> getOption ( 'general/accept_file_types' ) ) ] ; $ form = $ this -> createFormBuilder ( FileUploadType :: class , null , $ options ) -> getForm ( ) ; // Handle the upload. $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ this -> handleUpload ( $ form , $ directory ) ; return $ this -> redirectToRoute ( 'files' , [ 'path' => $ path , 'namespace' => $ namespace ] ) ; } if ( $ form -> isSubmitted ( ) && ! $ form -> isValid ( ) ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'general.phrase.file-upload-failed' ) ) ; } } // Select the correct template to render this. If we've got 'CKEditor' in the title, it's a dialog // from CKEditor to insert a file. $ template = $ request -> query -> has ( 'CKEditor' ) ? '@bolt/files_ck/files_ck.twig' : '@bolt/files/files.twig' ; $ context = [ 'directory' => $ directory , 'directories' => $ directories , 'files' => $ files , 'form' => $ form ? $ form -> createView ( ) : false , ] ; return $ this -> render ( $ template , $ context ) ; }
The file management browser.

@param Request $request   The Symfony Request
@param string  $namespace The filesystem namespace
@param string  $path      The path prefix

@return \Bolt\Response\TemplateResponse|\Symfony\Component\HttpFoundation\RedirectResponse
The file management browser .