Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sources/AppBundle/Accounting/Entity/Operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'compta_operation')]
class Operation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;

#[ORM\Column(name: 'operation', length: 255, nullable: false)]
public string $name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity\Repository;

use AppBundle\Accounting\Entity\Operation;
use AppBundle\Doctrine\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends EntityRepository<Operation>
*/
final class OperationRepository extends EntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Operation::class);
}
}
42 changes: 0 additions & 42 deletions sources/AppBundle/Accounting/Model/Operation.php

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

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;

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,
Expand Down
Loading