Moved export listing functionality from ExportController to a new ExportIndexController

for improved separation of concerns. Updated tests accordingly to reflect the new controller structure.
This commit is contained in:
Julien Fastré 2025-04-01 13:20:48 +02:00
parent 1375a41de2
commit 80d8f967fa
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 39 additions and 17 deletions

View File

@ -178,21 +178,6 @@ class ExportController extends AbstractController
return new Response('Ok: '.$exportGeneration->getId()->toString()); return new Response('Ok: '.$exportGeneration->getId()->toString());
} }
/**
* Render the list of available exports.
*/
#[Route(path: '/{_locale}/exports/', name: 'chill_main_export_index')]
public function indexAction(): Response
{
$exportManager = $this->exportManager;
$exports = $exportManager->getExportsGrouped(true);
return $this->render('@ChillMain/Export/layout.html.twig', [
'grouped_exports' => $exports,
]);
}
/** /**
* handle the step to build a query for an export. * handle the step to build a query for an export.
* *

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\Export\ExportManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment;
final readonly class ExportIndexController
{
public function __construct(private ExportManager $exportManager, private Environment $twig) {}
/**
* Render the list of available exports.
*/
#[Route(path: '/{_locale}/exports/', name: 'chill_main_export_index')]
public function indexAction(ExportController $exportController): Response
{
$exports = $this->exportManager->getExportsGrouped(true);
return new Response(
$this->twig->render('@ChillMain/Export/layout.html.twig', [
'grouped_exports' => $exports,
]),
);
}
}

View File

@ -21,13 +21,13 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* *
* @coversNothing * @coversNothing
*/ */
final class ExportControllerTest extends WebTestCase final class ExportIndexControllerTest extends WebTestCase
{ {
use PrepareClientTrait; use PrepareClientTrait;
public function testIndex() public function testIndex()
{ {
$client = $this->getClientAuthenticatedAsAdmin(); $client = $this->getClientAuthenticated();
$client->request('GET', '/fr/exports/'); $client->request('GET', '/fr/exports/');