1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 NdC/WBW |
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_SimpleFunction; |
15
|
|
|
use WBW\Library\Core\Utility\ArrayUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* ButtonComponentTwigExtension. |
19
|
|
|
* |
20
|
|
|
* @author Camille A. <[email protected]> |
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
22
|
|
|
*/ |
23
|
|
|
final class ButtonComponentTwigExtension extends AbstractComponentTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Service name. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.component.button"; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Displays a Bootstrap button "Danger". |
34
|
|
|
* |
35
|
|
|
* @param array $args The arguments. |
36
|
|
|
* @return string Returns the Bootstrap button "Danger". |
37
|
|
|
*/ |
38
|
|
|
public function bootstrapButtonDangerFunction(array $args = []) { |
39
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-danger", ArrayUtility::get($args, "icon")); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Displays a Bootstrap button "Default". |
44
|
|
|
* |
45
|
|
|
* @param array $args The arguments. |
46
|
|
|
* @return string Returns the Bootstrap button "Default". |
47
|
|
|
*/ |
48
|
|
|
public function bootstrapButtonDefaultFunction(array $args = []) { |
49
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-default", ArrayUtility::get($args, "icon")); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Displays a Bootstrap button "Info". |
54
|
|
|
* |
55
|
|
|
* @param array $args The arguments. |
56
|
|
|
* @return string Returns the Bootstrap button "Info". |
57
|
|
|
*/ |
58
|
|
|
public function bootstrapButtonInfoFunction(array $args = []) { |
59
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-info", ArrayUtility::get($args, "icon")); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Displays a Bootstrap button "Primary". |
64
|
|
|
* |
65
|
|
|
* @param array $args The arguments. |
66
|
|
|
* @return string Returns the Bootstrap button "Primary". |
67
|
|
|
*/ |
68
|
|
|
public function bootstrapButtonPrimaryFunction(array $args = []) { |
69
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-primary", ArrayUtility::get($args, "icon")); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Displays a Bootstrap button "Success". |
74
|
|
|
* |
75
|
|
|
* @param array $args The arguments. |
76
|
|
|
* @return string Returns the Bootstrap button "Success". |
77
|
|
|
*/ |
78
|
|
|
public function bootstrapButtonSuccessFunction(array $args = []) { |
79
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-success", ArrayUtility::get($args, "icon")); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Displays a Bootstrap button "Warning". |
84
|
|
|
* |
85
|
|
|
* @param array $args The arguments. |
86
|
|
|
* @return string Returns the Bootstrap button "Warning". |
87
|
|
|
*/ |
88
|
|
|
public function bootstrapButtonWarningFunction(array $args = []) { |
89
|
|
|
return $this->bootstrapButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "title"), ArrayUtility::get($args, "size", false), ArrayUtility::get($args, "block", false), ArrayUtility::get($args, "active", false), ArrayUtility::get($args, "disable", false), "btn-warning", ArrayUtility::get($args, "icon")); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get the Twig functions. |
94
|
|
|
* |
95
|
|
|
* @return array Returns the Twig functions. |
96
|
|
|
*/ |
97
|
|
|
public function getFunctions() { |
98
|
|
|
return [ |
99
|
|
|
new Twig_SimpleFunction("bootstrapButtonDanger", [$this, "bootstrapButtonDangerFunction"], ["is_safe" => ["html"]]), |
100
|
|
|
new Twig_SimpleFunction("bootstrapButtonDefault", [$this, "bootstrapButtonDefaultFunction"], ["is_safe" => ["html"]]), |
101
|
|
|
new Twig_SimpleFunction("bootstrapButtonInfo", [$this, "bootstrapButtonInfoFunction"], ["is_safe" => ["html"]]), |
102
|
|
|
new Twig_SimpleFunction("bootstrapButtonPrimary", [$this, "bootstrapButtonPrimaryFunction"], ["is_safe" => ["html"]]), |
103
|
|
|
new Twig_SimpleFunction("bootstrapButtonSuccess", [$this, "bootstrapButtonSuccessFunction"], ["is_safe" => ["html"]]), |
104
|
|
|
new Twig_SimpleFunction("bootstrapButtonWarning", [$this, "bootstrapButtonWarningFunction"], ["is_safe" => ["html"]]), |
105
|
|
|
]; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
} |
109
|
|
|
|