Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Index | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace App\Controller\Contracts; |
| 5 | |
| 6 | use App\Controller\BaseController; |
| 7 | use App\Repository\ContractRepository; |
| 8 | use App\Repository\StoreRepository; |
| 9 | use App\Repository\UserRepository; |
| 10 | use Symfony\Component\HttpFoundation\Request; |
| 11 | use Symfony\Component\HttpFoundation\Response; |
| 12 | use Symfony\Component\Routing\Attribute\Route; |
| 13 | use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 14 | |
| 15 | #[IsGranted('ROLE_ADMIN')] |
| 16 | #[Route(path: '/contracts', name: 'contracts_index', methods: ['GET', 'POST'])] |
| 17 | class Index extends BaseController |
| 18 | { |
| 19 | public function __construct( |
| 20 | private readonly StoreRepository $storeRepository, |
| 21 | private readonly UserRepository $userRepository, |
| 22 | private readonly ContractRepository $contractRepository |
| 23 | ) {} |
| 24 | |
| 25 | public function __invoke(Request $request): Response |
| 26 | { |
| 27 | $storeId = $request->request->getInt('store_id'); |
| 28 | $year = $request->request->getInt('year'); |
| 29 | |
| 30 | return $this->render( |
| 31 | 'contracts/index.html.twig', |
| 32 | [ |
| 33 | 'stores' => $this->storeRepository->findAll(), |
| 34 | 'users' => $this->userRepository->findActiveUsers(), |
| 35 | 'contracts' => $this->contractRepository->findContracts($storeId, $year), |
| 36 | 'year' => $year, |
| 37 | 'storeId' => $storeId, |
| 38 | ] |
| 39 | ); |
| 40 | } |
| 41 | } |