Passed
Pull Request — master (#300)
by Arnaud
15:59
created

UserMenuBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createMenu() 0 10 1
A __construct() 0 6 1
1
<?php
2
3
namespace LAG\AdminBundle\Bridge\KnpMenu\Builder;
4
5
use Knp\Menu\FactoryInterface;
6
use Knp\Menu\ItemInterface;
7
use LAG\AdminBundle\Translation\Helper\TranslationHelperInterface;
8
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
9
10
class UserMenuBuilder implements MenuBuilderInterface
11
{
12
    use MenuBuilderTrait;
13
14
    public function __construct(
15
        private FactoryInterface $factory,
16
        private TranslationHelperInterface $translationHelper,
17
        private EventDispatcherInterface $eventDispatcher,
18
    )
19
    {
20
    }
21
22
    public function createMenu(array $options = []): ItemInterface
23
    {
24
        $menu = $this->factory->createItem('root');
25
        $menu->addChild($this->translationHelper->getTranslationKey('logout'), [
26
            'route' => 'lag_admin.logout',
27
            'extras' => ['icon' => 'sign-out-alt'],
28
        ]);
29
        $this->dispatchMenuEvents('user', $menu);
30
31
        return $menu;
32
    }
33
}
34