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_SimpleFunction; |
15
|
|
|
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractABSBMDTwigExtension; |
16
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\Component\LabelComponentTwigExtension as BaseUITwigExtension; |
17
|
|
|
use WBW\Library\Core\Utility\Argument\ArrayUtility; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Label UI Twig extension. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI |
24
|
|
|
*/ |
25
|
|
|
class LabelUITwigExtension extends BaseUITwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Service name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
const SERVICE_NAME = "webeweb.bundle.adminbsbbundle.twig.extension.ui.label"; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor. |
36
|
|
|
*/ |
37
|
|
|
public function __construct() { |
38
|
|
|
parent::__construct(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get the Twig functions. |
43
|
|
|
* |
44
|
|
|
* @return array Returns the Twig functions. |
45
|
|
|
*/ |
46
|
|
|
public function getFunctions() { |
47
|
|
|
return [ |
48
|
|
|
new Twig_SimpleFunction("adminBSBLabelDanger", [$this, "bootstrapLabelDangerFunction"], ["is_safe" => ["html"]]), |
49
|
|
|
new Twig_SimpleFunction("adminBSBLabelDefault", [$this, "bootstrapLabelDefaultFunction"], ["is_safe" => ["html"]]), |
50
|
|
|
new Twig_SimpleFunction("adminBSBLabelInfo", [$this, "bootstrapLabelInfoFunction"], ["is_safe" => ["html"]]), |
51
|
|
|
new Twig_SimpleFunction("adminBSBLabelPrimary", [$this, "bootstrapLabelPrimaryFunction"], ["is_safe" => ["html"]]), |
52
|
|
|
new Twig_SimpleFunction("adminBSBLabelSuccess", [$this, "bootstrapLabelSuccessFunction"], ["is_safe" => ["html"]]), |
53
|
|
|
new Twig_SimpleFunction("adminBSBLabelWarning", [$this, "bootstrapLabelWarningFunction"], ["is_safe" => ["html"]]), |
54
|
|
|
new Twig_SimpleFunction("adminBSBMaterialDesignLabel", [$this, "adminBSBMaterialDesignLabelFunction"], ["is_safe" => ["html"]]), |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Displays an AdminBSB material design label. |
60
|
|
|
* |
61
|
|
|
* @param array $args The arguments. |
62
|
|
|
* @return string Returns the AdminBSB material design label. |
63
|
|
|
*/ |
64
|
|
|
public function adminBSBMaterialDesignLabelFunction(array $args = []) { |
65
|
|
|
return $this->bootstrapLabel(ArrayUtility::get($args, "content"), AbstractABSBMDTwigExtension::fixColor(ArrayUtility::get($args, "color", "red"), "bg-")); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|