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
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Button group Twig extension. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
21
|
|
|
* @link https://getbootstrap.com/docs/3.3/components/#btn-groups |
22
|
|
|
*/ |
23
|
|
|
class ButtonGroupTwigExtension extends AbstractButtonGroupTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Service name. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
const SERVICE_NAME = "wbw.bootstrap.twig.extension.component.button_group"; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Displays a Bootstrap button group "basic". |
34
|
|
|
* |
35
|
|
|
* @param array $args The arguments. |
36
|
|
|
* @param array $buttons The buttons. |
37
|
|
|
* @return string Returns the Bootstrap button group "basic". |
38
|
|
|
*/ |
39
|
|
|
public function bootstrapButtonGroupBasicFunction(array $args = [], array $buttons = []): string { |
40
|
|
|
return $this->bootstrapButtonGroup("btn-group", "group", $buttons); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Displays a Bootstrap button group "toolbar". |
45
|
|
|
* |
46
|
|
|
* @param array $args The arguments. |
47
|
|
|
* @param array $buttons The buttons. |
48
|
|
|
* @return string Returns the Bootstrap button group "toolbar". |
49
|
|
|
*/ |
50
|
|
|
public function bootstrapButtonGroupToolbarFunction(array $args = [], array $buttons = []): string { |
51
|
|
|
return $this->bootstrapButtonGroup("btn-toolbar", "toolbar", $buttons); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get the Twig functions. |
56
|
|
|
* |
57
|
|
|
* @return TwigFunction[] Returns the Twig functions. |
58
|
|
|
*/ |
59
|
|
|
public function getFunctions(): array { |
60
|
|
|
return [ |
61
|
|
|
new TwigFunction("bootstrapButtonGroupBasic", [$this, "bootstrapButtonGroupBasicFunction"], ["is_safe" => ["html"]]), |
62
|
|
|
new TwigFunction("bsButtonGroupBasic", [$this, "bootstrapButtonGroupBasicFunction"], ["is_safe" => ["html"]]), |
63
|
|
|
|
64
|
|
|
new TwigFunction("bootstrapButtonGroupToolbar", [$this, "bootstrapButtonGroupToolbarFunction"], ["is_safe" => ["html"]]), |
65
|
|
|
new TwigFunction("bsButtonGroupToolbar", [$this, "bootstrapButtonGroupToolbarFunction"], ["is_safe" => ["html"]]), |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|