|
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
|
|
|
|