Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Index | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Controller\Deposits; |
| 6 | |
| 7 | use App\Controller\BaseController; |
| 8 | use App\Helper\Paginator\PaginatorTrait; |
| 9 | use App\Repository\DepositRepository; |
| 10 | use Symfony\Component\DependencyInjection\Attribute\Autowire; |
| 11 | use Symfony\Component\HttpFoundation\Request; |
| 12 | use Symfony\Component\HttpFoundation\Response; |
| 13 | use Symfony\Component\Routing\Attribute\Route; |
| 14 | use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 15 | use function count; |
| 16 | |
| 17 | #[IsGranted('ROLE_ADMIN')] |
| 18 | #[Route(path: '/deposits', name: 'deposits_index', methods: ['GET', 'POST'])] |
| 19 | class Index extends BaseController |
| 20 | { |
| 21 | use PaginatorTrait; |
| 22 | |
| 23 | public function __construct(private readonly DepositRepository $depositRepository) {} |
| 24 | |
| 25 | public function __invoke( |
| 26 | Request $request, |
| 27 | #[Autowire('%env(LIST_LIMIT)%')] int $listLimit, |
| 28 | ): Response |
| 29 | { |
| 30 | $paginatorOptions = $this->getPaginatorOptions($request, $listLimit); |
| 31 | $deposits = $this->depositRepository->getPaginatedList($paginatorOptions); |
| 32 | $paginatorOptions->setMaxPages( |
| 33 | (int)ceil( |
| 34 | count($deposits) / $paginatorOptions->getLimit() |
| 35 | ) |
| 36 | ); |
| 37 | |
| 38 | return $this->render( |
| 39 | 'deposit/list.html.twig', |
| 40 | [ |
| 41 | 'deposits' => $deposits, |
| 42 | 'paginatorOptions' => $paginatorOptions, |
| 43 | ] |
| 44 | ); |
| 45 | } |
| 46 | } |