From 2b963c9f745d2dbe73c7842d0066306b574d1ef6 Mon Sep 17 00:00:00 2001 From: vgreb Date: Fri, 16 Jan 2026 13:17:21 +0100 Subject: [PATCH] =?UTF-8?q?Refonte=20Doctrine=20des=20types=20d'op=C3=A9ra?= =?UTF-8?q?tion=20de=20la=20tr=C3=A9sorerie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppBundle/Accounting/Entity/Operation.php | 20 +++++++++ .../Entity/Repository/OperationRepository.php | 20 +++++++++ .../AppBundle/Accounting/Model/Operation.php | 42 ------------------ .../Model/Repository/OperationRepository.php | 44 ------------------- .../Configuration/AddOperationAction.php | 6 +-- .../Configuration/EditOperationAction.php | 6 +-- .../Configuration/ListOperationAction.php | 6 +-- 7 files changed, 49 insertions(+), 95 deletions(-) create mode 100644 sources/AppBundle/Accounting/Entity/Operation.php create mode 100644 sources/AppBundle/Accounting/Entity/Repository/OperationRepository.php delete mode 100644 sources/AppBundle/Accounting/Model/Operation.php delete mode 100644 sources/AppBundle/Accounting/Model/Repository/OperationRepository.php diff --git a/sources/AppBundle/Accounting/Entity/Operation.php b/sources/AppBundle/Accounting/Entity/Operation.php new file mode 100644 index 000000000..cf3fe01ce --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/Operation.php @@ -0,0 +1,20 @@ + + */ +final class OperationRepository extends EntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Operation::class); + } +} diff --git a/sources/AppBundle/Accounting/Model/Operation.php b/sources/AppBundle/Accounting/Model/Operation.php deleted file mode 100644 index f15ce1793..000000000 --- a/sources/AppBundle/Accounting/Model/Operation.php +++ /dev/null @@ -1,42 +0,0 @@ -id; - } - - public function setId(int $id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): self - { - $this->propertyChanged('name', $this->name, $name); - $this->name = $name; - - return $this; - } -} diff --git a/sources/AppBundle/Accounting/Model/Repository/OperationRepository.php b/sources/AppBundle/Accounting/Model/Repository/OperationRepository.php deleted file mode 100644 index 9f02eb59b..000000000 --- a/sources/AppBundle/Accounting/Model/Repository/OperationRepository.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class OperationRepository extends Repository implements MetadataInitializer -{ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(Operation::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('compta_operation'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'operation', - 'fieldName' => 'name', - 'type' => 'string', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Controller/Admin/Accounting/Configuration/AddOperationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Configuration/AddOperationAction.php index 1fb799cd3..c9eb60bf9 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Configuration/AddOperationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Configuration/AddOperationAction.php @@ -5,8 +5,8 @@ namespace AppBundle\Controller\Admin\Accounting\Configuration; use AppBundle\Accounting\Form\OperationType; -use AppBundle\Accounting\Model\Operation; -use AppBundle\Accounting\Model\Repository\OperationRepository; +use AppBundle\Accounting\Entity\Operation; +use AppBundle\Accounting\Entity\Repository\OperationRepository; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -26,7 +26,7 @@ public function __invoke(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->operationRepository->save($operation); - $this->audit->log('Ajout de l\'opération ' . $operation->getName()); + $this->audit->log('Ajout de l\'opération ' . $operation->name); $this->addFlash('notice', 'L\'opération a été ajoutée'); return $this->redirectToRoute('admin_accounting_operations_list'); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Configuration/EditOperationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Configuration/EditOperationAction.php index 30bf56276..cbe3394f0 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Configuration/EditOperationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Configuration/EditOperationAction.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller\Admin\Accounting\Configuration; use AppBundle\Accounting\Form\OperationType; -use AppBundle\Accounting\Model\Repository\OperationRepository; +use AppBundle\Accounting\Entity\Repository\OperationRepository; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -20,12 +20,12 @@ public function __construct( public function __invoke(int $id,Request $request): Response { - $operation = $this->operationRepository->get($id); + $operation = $this->operationRepository->find($id); $form = $this->createForm(OperationType::class, $operation); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->operationRepository->save($operation); - $this->audit->log('Modification de l\'opération ' . $operation->getName()); + $this->audit->log('Modification de l\'opération ' . $operation->name); $this->addFlash('notice', 'L\'opération a été modifiée'); return $this->redirectToRoute('admin_accounting_operations_list'); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Configuration/ListOperationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Configuration/ListOperationAction.php index 3be99fe57..26c5c2a57 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Configuration/ListOperationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Configuration/ListOperationAction.php @@ -4,7 +4,7 @@ namespace AppBundle\Controller\Admin\Accounting\Configuration; -use AppBundle\Accounting\Model\Repository\OperationRepository; +use AppBundle\Accounting\Entity\Repository\OperationRepository; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; @@ -12,13 +12,13 @@ class ListOperationAction { public function __construct( - private readonly OperationRepository $accountRepository, + private readonly OperationRepository $operationRepository, private readonly Environment $twig, ) {} public function __invoke(Request $request): Response { - $operations = $this->accountRepository->getAll(); + $operations = $this->operationRepository->findAll(); return new Response($this->twig->render('admin/accounting/configuration/operation_list.html.twig', [ 'operations' => $operations,