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
3namespace App\Controller\User;
4
5use App\Controller\BaseController;
6use App\Enum\UserRole;
7use App\Repository\AgentStatRepository;
8use App\Repository\UserRepository;
9use Symfony\Component\HttpFoundation\Response;
10use Symfony\Component\Routing\Attribute\Route;
11use Symfony\Component\Security\Http\Attribute\IsGranted;
12
13/**
14 * Every user, with the agent, the privacy settings and every picture (as the app's admin agents).
15 */
16#[Route('/admin/agents', name: 'app_user_index', methods: ['GET'])]
17#[IsGranted(UserRole::ADMIN->value)]
18final class Index extends BaseController
19{
20    public function __invoke(UserRepository $userRepository, AgentStatRepository $agentStatRepository): Response
21    {
22        $users = $userRepository->findAllByAgentName();
23
24        return $this->render('user/index.html.twig', [
25            'users' => $users,
26            'latest' => $agentStatRepository->findLatestByOwners($users),
27        ]);
28    }
29}