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

UserMenuBuilder::createMenu()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
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