adminBSBMultiLevelMenuFunction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\AdminBSBBundle\Twig\Extension\Menu;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Twig\TwigFunction;
16
use WBW\Bundle\CoreBundle\Navigation\NavigationTree;
17
use WBW\Bundle\CoreBundle\Navigation\NavigationTreeHelper;
18
19
/**
20
 * Multi level menu Twig extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Menu
24
 */
25
class MultiLevelMenuTwigExtension extends AbstractMenuTwigExtension {
26
27
    /**
28
     * Service name.
29
     *
30
     * @var string
31
     */
32
    const SERVICE_NAME = "wbw.adminbsb.twig.extension.menu.multi_level_menu";
33
34
    /**
35
     * Displays an AdminBSB multi level menu.
36
     *
37
     * @param NavigationTree $tree The tree.
38
     * @param Request $request The request.
39
     * @return string Returns the AdminBSB multi level menu.
40
     */
41
    public function adminBSBMultiLevelMenuFunction(NavigationTree $tree, Request $request): string {
42
        NavigationTreeHelper::activeTree($tree, $request);
43
        return $this->adminBSBMenu($tree);
44
    }
45
46
    /**
47
     * Get the Twig functions.
48
     *
49
     * @return TwigFunction[] Returns the Twig functions.
50
     */
51
    public function getFunctions(): array {
52
        return [
53
            new TwigFunction("adminBSBMultiLevelMenu", [$this, "adminBSBMultiLevelMenuFunction"], ["is_safe" => ["html"]]),
54
        ];
55
    }
56
}
57