Lines
100.00%
5 / 5
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Index | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 1 | 100.00% | 1 / 1 | |||
| __invoke | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Controller\Agent; | |
| 6 | ||
| 7 | use App\Controller\BaseController; | |
| 8 | use App\Enum\UserRole; | |
| 9 | use App\Repository\AgentStatRepository; | |
| 10 | use App\Repository\UserRepository; | |
| 11 | use Symfony\Component\HttpFoundation\Response; | |
| 12 | use Symfony\Component\Routing\Attribute\Route; | |
| 13 | use Symfony\Component\Security\Http\Attribute\IsGranted; | |
| 14 | ||
| 15 | /** | |
| 16 | * The agents who show their profile to other users (admins too; every user is on User\\Index). | |
| 17 | */ | |
| 18 | #[Route('/agents', name: 'app_agent_index', methods: ['GET'])] | |
| 19 | #[IsGranted(UserRole::USER->value)] | |
| 20 | final class Index extends BaseController | |
| 21 | { | |
| 22 | public function __invoke(UserRepository $userRepository, AgentStatRepository $agentStatRepository): Response | |
| 23 | { | |
| 24 | $agents = $userRepository->findVisibleAgents(); | |
| 25 | ||
| 26 | return $this->render('agent/index.html.twig', [ | |
| 27 | 'agents' => $agents, | |
| 28 | 'latest' => $agentStatRepository->findLatestByOwners($agents), | |
| 29 | ]); | |
| 30 | } | |
| 31 | } |