Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Menu
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
51.55
0.00% covered (danger)
0.00%
0 / 1
 __construct
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
51.55
1<?php
2
3namespace App\Menu;
4
5use App\Application;
6use App\Security\Action;
7use App\Security\User;
8use Symfony\Bundle\SecurityBundle\Security;
9
10class Menu extends MenuBase
11{
12    public function __construct(MenuTwig $menuTwig, Security $security, Application $application)
13    {
14        parent::__construct($menuTwig);
15        /** @var ?User $user */
16        $user = $security->getUser();
17
18        $menuTwig->addItem(
19            'redaction_right',
20            new MenuItem(
21                'idConnexion',
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
23                'info'
24            )
25        );
26        if ($user?->hasLogout()) {
27            $menuTwig->addItem('redaction_right', new MenuItem('id_disconnection', 'Se dĂ©connecter', 'saml_logout'));
28        }
29        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
30            $menuTwig->addItem(
31                'redaction_right',
32                new MenuItem(
33                    'environnement',
34                    '<span class="badge rounded-pill ' . $application->getServerType() .
35                    '" data-bs-toggle="tooltip" title="Vous ĂȘtes dans l\'environnement de ' .
36                    $application->getServerType() . "\nVersion : " . $application->getVersion() .
37                    '">' . $application->getServerType() . '</span>'
38                )
39            );
40        }
41        $subSettingsMenus = [];
42        if ($security->isGranted(Action::ADMIN_PAGE)) {
43            $subSettingsMenus[] = new MenuItem('admin_page', 'Administration', 'admin_page');
44        }
45        if ($security->isGranted(Action::HOMEPAGE)) {
46            $subSettingsMenus[] = new MenuItem('homepage', 'Accueil', 'homepage');
47        }
48        if ([] !== $subSettingsMenus) {
49            $menuTwig->addItem(
50                'redaction_right',
51                new MenuItem('settings', '<i class="bi bi-gear"></i>', null, [], [], $subSettingsMenus)
52            );
53        }
54    }
55}