MenuConfigureListener::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Event\Listener;
17
18
use Veslo\AnthillBundle\Menu\Builder;
19
use Veslo\AppBundle\Event\Menu\ConfigureEvent;
20
21
/**
22
 * A bridge between application level menu builder and bundle menu builder
23
 */
24
class MenuConfigureListener
25
{
26
    /**
27
     * Bundle-specific menu builder
28
     *
29
     * @var Builder
30
     */
31
    private $menuBuilder;
32
33
    /**
34
     * MenuConfigureListener constructor.
35
     *
36
     * @param Builder $menuBuilder Bundle-specific menu builder
37
     */
38
    public function __construct(Builder $menuBuilder)
39
    {
40
        $this->menuBuilder = $menuBuilder;
41
    }
42
43
    /**
44
     * Calls bundle-specific menu builder to append available items to root of application menu
45
     *
46
     * @param ConfigureEvent $event Menu configure event to allow a menu to be extended by different bundles
47
     *
48
     * @return void
49
     */
50
    public function onMenuConfigure(ConfigureEvent $event): void
51
    {
52
        $root = $event->getRoot();
53
54
        $this->menuBuilder->appendTo($root);
55
    }
56
}
57