Passed
Push — develop ( cab935...023a48 )
by BENARD
03:29
created

statisticsAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 20
rs 9.7998
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ProjetNormandie\UserBundle\Controller\Admin;
4
5
use ProjetNormandie\UserBundle\Admin\Extension\SecurityEventStatisticsExtension;
6
use Sonata\AdminBundle\Controller\CRUDController;
7
use Symfony\Component\HttpFoundation\Response;
8
9
class SecurityEventStatisticsController extends CRUDController
10
{
11
    public function __construct(
12
        private readonly SecurityEventStatisticsExtension $statisticsExtension
13
    ) {
14
    }
15
16
    public function statisticsAction(): Response
17
    {
18
        $statistics = $this->statisticsExtension->getSecurityStatistics(4);
19
        $trends = $this->statisticsExtension->getWeeklyTrends(4);
20
        
21
        // Préparer les types d'événements pour le template
22
        $eventTypes = [
23
            'password_change' => \ProjetNormandie\UserBundle\Security\Event\SecurityEventTypeEnum::PASSWORD_CHANGE,
24
            'password_reset_request' => \ProjetNormandie\UserBundle\Security\Event\SecurityEventTypeEnum::PASSWORD_RESET_REQUEST,
25
            'password_reset_complete' => \ProjetNormandie\UserBundle\Security\Event\SecurityEventTypeEnum::PASSWORD_RESET_COMPLETE,
26
            'email_change' => \ProjetNormandie\UserBundle\Security\Event\SecurityEventTypeEnum::EMAIL_CHANGE,
27
            'registration' => \ProjetNormandie\UserBundle\Security\Event\SecurityEventTypeEnum::REGISTRATION,
28
        ];
29
30
        return $this->renderWithExtraParams('@ProjetNormandieUser/Admin/security_statistics.html.twig', [
0 ignored issues
show
Deprecated Code introduced by
The function Sonata\AdminBundle\Contr...renderWithExtraParams() has been deprecated: since sonata-project/admin-bundle version 4.x ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

30
        return /** @scrutinizer ignore-deprecated */ $this->renderWithExtraParams('@ProjetNormandieUser/Admin/security_statistics.html.twig', [

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
31
            'statistics' => $statistics,
32
            'trends' => $trends,
33
            'eventTypes' => $eventTypes,
34
            'admin' => $this->admin,
35
            'object' => null,
36
        ]);
37
    }
38
}