minor changes

This commit is contained in:
2024-12-04 22:23:28 +01:00
parent e70c6db10f
commit 2123b5464f
22 changed files with 1045 additions and 27 deletions

View File

@ -2,6 +2,8 @@
namespace App\Controller;
use App\Forms\UploadFileForm;
use App\Objects\UploadedFileData;
use App\Service\FileSystemService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@ -10,11 +12,25 @@ use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
#[Route(path: '/', name: 'app_home', methods: Request::METHOD_GET)]
#[Route(path: '/', name: 'app_home', methods: [Request::METHOD_GET, Request::METHOD_POST])]
public function __invoke(
FileSystemService $fileSystemService
FileSystemService $fileSystemService,
Request $request,
): Response
{
return $this->render('home.html.twig', ['content' => $fileSystemService->getDirs()]);
$fileData = new UploadedFileData();
$form = $this->createForm(UploadFileForm::class, $fileData)->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
dd($form->getData(), $form->getExtraData());
$fileSystemService->uploadFile($fileData->file);
return $this->redirectToRoute('app_home');
}
return $this->render('home.html.twig', [
'content' => $fileSystemService->getDirs(),
'fileForm' => $form,
]);
}
}