Completed
Push — master ( a3d6f2...653760 )
by WEBEWEB
02:00
created

bootstrapBreadcrumbsFunction()   A

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 3
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-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\BootstrapBundle\Twig\Extension\Component;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\Translation\TranslatorInterface;
16
use Twig_SimpleFunction;
17
use WBW\Bundle\BootstrapBundle\Helper\NavigationTreeHelper;
18
use WBW\Bundle\BootstrapBundle\Navigation\NavigationTree;
19
20
/**
21
 * BreadcrumbComponentTwigExtension.
22
 *
23
 * @author Camille A. <[email protected]>
24
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
25
 */
26
class BreadcrumbComponentTwigExtension extends AbstractComponentTwigExtension {
27
28
    /**
29
     * Service name.
30
     *
31
     * @var string
32
     */
33
    const SERVICE_NAME = "webeweb.bootstrapbundle.twig.extension.component.breadcrumb";
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param TranslatorInterface $translator The translator.
39
     */
40
    public function __construct(TranslatorInterface $translator) {
41
        parent::__construct($translator);
42
    }
43
44
    /**
45
     * Displays a Bootstrap breadcrumbs.
46
     *
47
     * @param array $args The arguments.
48
     * @param NavigationTree $tree The tree.
49
     * @param Request $request The request.
50
     * @return string Returns the Bootstrap breadcrumbs.
51
     */
52
    public function bootstrapBreadcrumbsFunction(array $args = [], NavigationTree $tree, Request $request) {
53
        NavigationTreeHelper::activeTree($tree, $request);
54
        return $this->bootstrapBreadcrumbs($tree, $request);
55
    }
56
57
    /**
58
     * Get the Twig functions.
59
     *
60
     * @return Twig_SimpleFunction[] Returns the Twig functions.
61
     */
62
    public function getFunctions() {
63
        return [
64
            new Twig_SimpleFunction("bootstrapBreadcrumbs", [$this, "bootstrapBreadcrumbsFunction"], ["is_safe" => ["html"]]),
65
        ];
66
    }
67
68
}
69