add route parameter for dirs
This commit is contained in:
parent
bf226d7e3f
commit
07a54729b1
@ -11,11 +11,17 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
|
|
||||||
class HomeController extends AbstractController
|
class HomeController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route(path: '/files', name: 'app_home', methods: [Request::METHOD_GET])]
|
#[Route(
|
||||||
public function __invoke(FileSystemService $fileSystemService): Response
|
path: '/files/{dirs?}',
|
||||||
|
name: 'app_home',
|
||||||
|
requirements: ['dirs' => '.+'],
|
||||||
|
defaults: ['dirs' => ''],
|
||||||
|
methods: [Request::METHOD_GET]
|
||||||
|
)]
|
||||||
|
public function __invoke(FileSystemService $fileSystemService, string $dirs): Response
|
||||||
{
|
{
|
||||||
return $this->render('home.html.twig', [
|
return $this->render('home.html.twig', [
|
||||||
'content' => $fileSystemService->getDirs(),
|
'content' => $fileSystemService->getDirs($dirs),
|
||||||
'fileForm' => $this->createForm(UploadFileForm::class),
|
'fileForm' => $this->createForm(UploadFileForm::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ class FileSystemService
|
|||||||
/**
|
/**
|
||||||
* @return DirContent[]
|
* @return DirContent[]
|
||||||
*/
|
*/
|
||||||
public function getDirs(): array
|
public function getDirs(string $dirs): array
|
||||||
{
|
{
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$finder->in($this->dir);
|
$finder->in($this->dir . '/' . $dirs);
|
||||||
|
|
||||||
$contents = [];
|
$contents = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user