|
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 Twig\TwigFunction; |
|
15
|
|
|
use WBW\Library\Core\Argument\Helper\ArrayHelper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Nav component Twig extension. |
|
19
|
|
|
* |
|
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
|
22
|
|
|
* @link https://getbootstrap.com/docs/3.3/components/#nav |
|
23
|
|
|
*/ |
|
24
|
|
|
class NavTwigExtension extends AbstractNavTwigExtension { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Service name. |
|
28
|
|
|
* |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
const SERVICE_NAME = "wbw.bootstrap.twig.extension.component.nav"; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Displays a Bootstrap navs "justified". |
|
35
|
|
|
* |
|
36
|
|
|
* @param array $args The arguments. |
|
37
|
|
|
* @return string Returns the Bootstrap nav "justified". |
|
38
|
|
|
*/ |
|
39
|
|
|
public function bootstrapNavsJustified(array $args = []): string { |
|
40
|
|
|
return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-justified", false); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Displays a Bootstrap navs "pills". |
|
45
|
|
|
* |
|
46
|
|
|
* @param array $args The arguments. |
|
47
|
|
|
* @return string Returns the Bootstrap nav "pills". |
|
48
|
|
|
*/ |
|
49
|
|
|
public function bootstrapNavsPills(array $args = []): string { |
|
50
|
|
|
return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-pills", ArrayHelper::get($args, "stacked", false)); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Displays a Bootstrap navs "tabs". |
|
55
|
|
|
* |
|
56
|
|
|
* @param array $args The arguments. |
|
57
|
|
|
* @return string Returns the Bootstrap nav "tabs". |
|
58
|
|
|
*/ |
|
59
|
|
|
public function bootstrapNavsTabs(array $args = []): string { |
|
60
|
|
|
return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-tabs", false); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get the Twig functions. |
|
65
|
|
|
* |
|
66
|
|
|
* @return TwigFunction[] Returns the Twig functions. |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getFunctions(): array { |
|
69
|
|
|
return [ |
|
70
|
|
|
new TwigFunction("bootstrapNavsJustified", [$this, "bootstrapNavsJustifiedFunction"], ["is_safe" => ["html"]]), |
|
71
|
|
|
new TwigFunction("bsNavsJustified", [$this, "bootstrapNavsJustifiedFunction"], ["is_safe" => ["html"]]), |
|
72
|
|
|
|
|
73
|
|
|
new TwigFunction("bootstrapNavsPills", [$this, "bootstrapNavsPillsFunction"], ["is_safe" => ["html"]]), |
|
74
|
|
|
new TwigFunction("bsNavsPills", [$this, "bootstrapNavsPillsFunction"], ["is_safe" => ["html"]]), |
|
75
|
|
|
|
|
76
|
|
|
new TwigFunction("bootstrapNavsTabs", [$this, "bootstrapNavsTabsFunction"], ["is_safe" => ["html"]]), |
|
77
|
|
|
new TwigFunction("bsNavsTabs", [$this, "bootstrapNavsTabsFunction"], ["is_safe" => ["html"]]), |
|
78
|
|
|
]; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|