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_SimpleFunction; |
15
|
|
|
use WBW\Bundle\BootstrapBundle\BootstrapInterface; |
16
|
|
|
use WBW\Library\Core\Argument\ArrayHelper; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Label Twig extension. |
20
|
|
|
* |
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
22
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
23
|
|
|
* @link https://getbootstrap.com/docs/3.3/components/#labels |
24
|
|
|
*/ |
25
|
|
|
class LabelTwigExtension extends AbstractLabelTwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Service name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.label"; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Displays a Bootstrap label "Danger". |
36
|
|
|
* |
37
|
|
|
* @param array $args The arguments. |
38
|
|
|
* @return string Returns the Bootstrap label "Danger". |
39
|
|
|
*/ |
40
|
|
|
public function bootstrapLabelDangerFunction(array $args = []) { |
41
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_DANGER); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Displays a Bootstrap label "Default". |
46
|
|
|
* |
47
|
|
|
* @param array $args The arguments. |
48
|
|
|
* @return string Returns the Bootstrap label "Default". |
49
|
|
|
*/ |
50
|
|
|
public function bootstrapLabelDefaultFunction(array $args = []) { |
51
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_DEFAULT); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Displays a Bootstrap label "Info". |
56
|
|
|
* |
57
|
|
|
* @param array $args The arguments. |
58
|
|
|
* @return string Returns the Bootstrap label "Info". |
59
|
|
|
*/ |
60
|
|
|
public function bootstrapLabelInfoFunction(array $args = []) { |
61
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_INFO); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Displays a Bootstrap label "Primary". |
66
|
|
|
* |
67
|
|
|
* @param array $args The arguments. |
68
|
|
|
* @return string Returns the Bootstrap label "Primary". |
69
|
|
|
*/ |
70
|
|
|
public function bootstrapLabelPrimaryFunction(array $args = []) { |
71
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_PRIMARY); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Displays a Bootstrap label "Success". |
76
|
|
|
* |
77
|
|
|
* @param array $args The arguments. |
78
|
|
|
* @return string Returns the Bootstrap label "Success". |
79
|
|
|
*/ |
80
|
|
|
public function bootstrapLabelSuccessFunction(array $args = []) { |
81
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_SUCCESS); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Displays a Bootstrap label "Warning". |
86
|
|
|
* |
87
|
|
|
* @param array $args The arguments. |
88
|
|
|
* @return string Returns the Bootstrap label "Warning". |
89
|
|
|
*/ |
90
|
|
|
public function bootstrapLabelWarningFunction(array $args = []) { |
91
|
|
|
return $this->bootstrapLabel(ArrayHelper::get($args, "content"), "label-" . BootstrapInterface::BOOTSTRAP_WARNING); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get the Twig functions. |
96
|
|
|
* |
97
|
|
|
* @return Twig_SimpleFunction[] Returns the Twig functions. |
98
|
|
|
*/ |
99
|
|
|
public function getFunctions() { |
100
|
|
|
return [ |
101
|
|
|
new Twig_SimpleFunction("bootstrapLabelDanger", [$this, "bootstrapLabelDangerFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
102
|
|
|
new Twig_SimpleFunction("bsLabelDanger", [$this, "bootstrapLabelDangerFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
103
|
|
|
|
104
|
|
|
new Twig_SimpleFunction("bootstrapLabelDefault", [$this, "bootstrapLabelDefaultFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
105
|
|
|
new Twig_SimpleFunction("bsLabelDefault", [$this, "bootstrapLabelDefaultFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
106
|
|
|
|
107
|
|
|
new Twig_SimpleFunction("bootstrapLabelInfo", [$this, "bootstrapLabelInfoFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
108
|
|
|
new Twig_SimpleFunction("bsLabelInfo", [$this, "bootstrapLabelInfoFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
109
|
|
|
|
110
|
|
|
new Twig_SimpleFunction("bootstrapLabelPrimary", [$this, "bootstrapLabelPrimaryFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
111
|
|
|
new Twig_SimpleFunction("bsLabelPrimary", [$this, "bootstrapLabelPrimaryFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
112
|
|
|
|
113
|
|
|
new Twig_SimpleFunction("bootstrapLabelSuccess", [$this, "bootstrapLabelSuccessFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
114
|
|
|
new Twig_SimpleFunction("bsLabelSuccess", [$this, "bootstrapLabelSuccessFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
115
|
|
|
|
116
|
|
|
new Twig_SimpleFunction("bootstrapLabelWarning", [$this, "bootstrapLabelWarningFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
117
|
|
|
new Twig_SimpleFunction("bsLabelWarning", [$this, "bootstrapLabelWarningFunction"], ["is_safe" => ["html"]]), |
|
|
|
|
118
|
|
|
]; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.