BreadcrumbTwigExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrapBreadcrumbsFunction() 0 4 1
A getFunctions() 0 6 1
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 Twig\TwigFunction;
16
use WBW\Bundle\CoreBundle\Navigation\NavigationTree;
17
use WBW\Bundle\CoreBundle\Navigation\NavigationTreeHelper;
18
19
/**
20
 * Breadcrumb Twig Extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
24
 * @link https://getbootstrap.com/docs/3.3/components/#breadcrumbs
25
 */
26
class BreadcrumbTwigExtension extends AbstractBreadcrumbTwigExtension {
27
28
    /**
29
     * Service name.
30
     *
31
     * @var string
32
     */
33
    const SERVICE_NAME = "wbw.bootstrap.twig.extension.component.breadcrumb";
34
35
    /**
36
     * Displays a Bootstrap breadcrumbs.
37
     *
38
     * @param array $args The arguments.
39
     * @param NavigationTree $tree The tree.
40
     * @param Request $request The request.
41
     * @return string Returns the Bootstrap breadcrumbs.
42
     */
43
    public function bootstrapBreadcrumbsFunction(array $args = [], NavigationTree $tree, Request $request): string {
44
        NavigationTreeHelper::activeTree($tree, $request);
45
        return $this->bootstrapBreadcrumbs($tree);
46
    }
47
48
    /**
49
     * Get the Twig functions.
50
     *
51
     * @return TwigFunction[] Returns the Twig functions.
52
     */
53
    public function getFunctions(): array {
54
        return [
55
            new TwigFunction("bootstrapBreadcrumbs", [$this, "bootstrapBreadcrumbsFunction"], ["is_safe" => ["html"]]),
56
            new TwigFunction("bsBreadcrumbs", [$this, "bootstrapBreadcrumbsFunction"], ["is_safe" => ["html"]]),
57
        ];
58
    }
59
}
60