1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the adminbsb-material-design-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 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\AdminBSBBundle\Twig\Extension\UI; |
13
|
|
|
|
14
|
|
|
use Twig_SimpleFilter; |
15
|
|
|
use Twig_SimpleFunction; |
16
|
|
|
use WBW\Bundle\AdminBSBBundle\Button\ButtonFactory; |
17
|
|
|
use WBW\Library\Core\Argument\ArrayHelper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Button Twig extension. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI |
24
|
|
|
*/ |
25
|
|
|
class ButtonTwigExtension extends AbstractButtonTwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Service name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
const SERVICE_NAME = "webeweb.adminbsb.twig.extension.ui.button"; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Displays an AdminBSB button "Danger". |
36
|
|
|
* |
37
|
|
|
* @param array $args The arguments. |
38
|
|
|
* @return string Returns the AdminBSB button "Danger". |
39
|
|
|
*/ |
40
|
|
|
public function adminBSBButtonDangerFunction(array $args = []) { |
41
|
|
|
return $this->adminBSBButton(ButtonFactory::parseDangerButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Displays an AdminBSB button "Default". |
46
|
|
|
* |
47
|
|
|
* @param array $args The arguments. |
48
|
|
|
* @return string Returns the AdminBSB button "Default". |
49
|
|
|
*/ |
50
|
|
|
public function adminBSBButtonDefaultFunction(array $args = []) { |
51
|
|
|
return $this->adminBSBButton(ButtonFactory::parseDefaultButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Displays an AdminBSB button "Info". |
56
|
|
|
* |
57
|
|
|
* @param array $args The arguments. |
58
|
|
|
* @return string Returns the AdminBSB button "Info". |
59
|
|
|
*/ |
60
|
|
|
public function adminBSBButtonInfoFunction(array $args = []) { |
61
|
|
|
return $this->adminBSBButton(ButtonFactory::parseInfoButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Displays a AdminBSB button "Material design". |
66
|
|
|
* |
67
|
|
|
* @param array $args The arguments. |
68
|
|
|
* @return string Returns the AdminBSB button "Material design". |
69
|
|
|
*/ |
70
|
|
|
public function adminBSBButtonMaterialDesignFunction(array $args = []) { |
71
|
|
|
return $this->adminBSBButton(ButtonFactory::parseMaterialDesignButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Displays an AdminBSB button "Primary". |
76
|
|
|
* |
77
|
|
|
* @param array $args The arguments. |
78
|
|
|
* @return string Returns the AdminBSB button "Primary". |
79
|
|
|
*/ |
80
|
|
|
public function adminBSBButtonPrimaryFunction(array $args = []) { |
81
|
|
|
return $this->adminBSBButton(ButtonFactory::parsePrimaryButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Displays an AdminBSB button "Success". |
86
|
|
|
* |
87
|
|
|
* @param array $args The arguments. |
88
|
|
|
* @return string Returns the AdminBSB button "Success". |
89
|
|
|
*/ |
90
|
|
|
public function adminBSBButtonSuccessFunction(array $args = []) { |
91
|
|
|
return $this->adminBSBButton(ButtonFactory::parseSuccessButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Displays an AdminBSB button "Warning". |
96
|
|
|
* |
97
|
|
|
* @param array $args The arguments. |
98
|
|
|
* @return string Returns the AdminBSB button "Warning". |
99
|
|
|
*/ |
100
|
|
|
public function adminBSBButtonWarningFunction(array $args = []) { |
101
|
|
|
return $this->adminBSBButton(ButtonFactory::parseWarningButton($args), ArrayHelper::get($args, "icon"), ArrayHelper::get($args, "circle", false)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get the Twig filters. |
106
|
|
|
* |
107
|
|
|
* @return array Returns the Twig filters. |
108
|
|
|
*/ |
109
|
|
|
public function getFilters() { |
110
|
|
|
return [ |
111
|
|
|
new Twig_SimpleFilter("adminBSBButtonLink", [$this, "bootstrapButtonLinkFilter"], ["is_safe" => ["html"]]), |
112
|
|
|
new Twig_SimpleFilter("adminBSBButtonSubmit", [$this, "bootstrapButtonSubmitFilter"], ["is_safe" => ["html"]]), |
113
|
|
|
]; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get the Twig functions. |
118
|
|
|
* |
119
|
|
|
* @return array Returns the Twig functions. |
120
|
|
|
*/ |
121
|
|
|
public function getFunctions() { |
122
|
|
|
return [ |
123
|
|
|
new Twig_SimpleFunction("adminBSBButtonDanger", [$this, "adminBSBButtonDangerFunction"], ["is_safe" => ["html"]]), |
124
|
|
|
new Twig_SimpleFunction("adminBSBButtonDefault", [$this, "adminBSBButtonDefaultFunction"], ["is_safe" => ["html"]]), |
125
|
|
|
new Twig_SimpleFunction("adminBSBButtonInfo", [$this, "adminBSBButtonInfoFunction"], ["is_safe" => ["html"]]), |
126
|
|
|
new Twig_SimpleFunction("adminBSBButtonMaterialDesign", [$this, "adminBSBButtonMaterialDesignFunction"], ["is_safe" => ["html"]]), |
127
|
|
|
new Twig_SimpleFunction("adminBSBButtonPrimary", [$this, "adminBSBButtonPrimaryFunction"], ["is_safe" => ["html"]]), |
128
|
|
|
new Twig_SimpleFunction("adminBSBButtonSuccess", [$this, "adminBSBButtonSuccessFunction"], ["is_safe" => ["html"]]), |
129
|
|
|
new Twig_SimpleFunction("adminBSBButtonWarning", [$this, "adminBSBButtonWarningFunction"], ["is_safe" => ["html"]]), |
130
|
|
|
]; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|