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\AdminBSBMaterialDesignBundle\Twig\Extension\UI; |
13
|
|
|
|
14
|
|
|
use Twig_SimpleFunction; |
15
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\Component\AlertComponentTwigExtension as BaseUITwigExtension; |
16
|
|
|
use WBW\Library\Core\Utility\ArrayUtility; |
17
|
|
|
use WBW\Library\Core\Utility\StringUtility; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Alert UI Twig extension. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\AdminBSBMaterialDesignBundle\Twig\Extension\UI |
24
|
|
|
* @final |
25
|
|
|
*/ |
26
|
|
|
final class AlertUITwigExtension extends AbstractUITwigExtension { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Service name. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
const SERVICE_NAME = "webeweb.bundle.adminbsbmaterialdesignbundle.twig.extension.ui.alert"; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Displays an basic alert "Danger". |
37
|
|
|
* |
38
|
|
|
* @param array $args The arguments. |
39
|
|
|
* @return string Returns the basic alert "Danger". |
40
|
|
|
*/ |
41
|
|
|
public function absbmdBasicAlertDangerFunction(array $args = []) { |
42
|
|
|
return (new BaseUITwigExtension())->bootstrapAlertDangerFunction($args); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Displays an AdminBSB basic alert "Info". |
47
|
|
|
* |
48
|
|
|
* @param array $args The arguments. |
49
|
|
|
* @return string Returns the AdminBSB basic alert "Info". |
50
|
|
|
*/ |
51
|
|
|
public function absbmdBasicAlertInfoFunction(array $args = []) { |
52
|
|
|
return (new BaseUITwigExtension())->bootstrapAlertInfoFunction($args); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Displays an AdminBSB basic alert "Success". |
57
|
|
|
* |
58
|
|
|
* @param array $args The arguments. |
59
|
|
|
* @return string Returns the AdminBSB basic alert "Success". |
60
|
|
|
*/ |
61
|
|
|
public function absbmdBasicAlertSuccessFunction(array $args = []) { |
62
|
|
|
return (new BaseUITwigExtension())->bootstrapAlertSuccessFunction($args); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Displays an AdminBSB basic alert "Warning". |
67
|
|
|
* |
68
|
|
|
* @param array $args The arguments. |
69
|
|
|
* @return string Returns the AdminBSB basic alert "Warning". |
70
|
|
|
*/ |
71
|
|
|
public function absbmdBasicAlertWarningFunction(array $args = []) { |
72
|
|
|
return (new BaseUITwigExtension())->bootstrapAlertWarningFunction($args); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get the Twig functions. |
77
|
|
|
* |
78
|
|
|
* @return array Returns the Twig functions. |
79
|
|
|
*/ |
80
|
|
|
public function getFunctions() { |
81
|
|
|
return [ |
82
|
|
|
new Twig_SimpleFunction("absbmdBasicAlertDanger", [$this, "absbmdBasicAlertDangerFunction"], ["is_safe" => ["html"]]), |
83
|
|
|
new Twig_SimpleFunction("absbmdBasicAlertInfo", [$this, "absbmdBasicAlertInfoFunction"], ["is_safe" => ["html"]]), |
84
|
|
|
new Twig_SimpleFunction("absbmdBasicAlertSuccess", [$this, "absbmdBasicAlertSuccessFunction"], ["is_safe" => ["html"]]), |
85
|
|
|
new Twig_SimpleFunction("absbmdBasicAlertWarning", [$this, "absbmdBasicAlertWarningFunction"], ["is_safe" => ["html"]]), |
86
|
|
|
new Twig_SimpleFunction("absbmdLinkAlert", [$this, "absbmdLinkAlertFunction"], ["is_safe" => ["html"]]), |
87
|
|
|
new Twig_SimpleFunction("absbmdMaterialDesignAlert", [$this, "absbmdMaterialDesignAlertFunction"], ["is_safe" => ["html"]]), |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Displays an AdminBSB link alert. |
93
|
|
|
* |
94
|
|
|
* @param array $args The arguments. |
95
|
|
|
* @return string Returns the AdminBSB link alert. |
96
|
|
|
*/ |
97
|
|
|
public function absbmdLinkAlertFunction(array $args = []) { |
98
|
|
|
return (new BaseUITwigExtension())->bootstrapLinkAlertFunction($args); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Displays an AdminBSB material design alert. |
103
|
|
|
* |
104
|
|
|
* @param array $args The arguments. |
105
|
|
|
* @return string Returns the AdminBSB material design alert. |
106
|
|
|
*/ |
107
|
|
|
public function absbmdMaterialDesignAlertFunction(array $args = []) { |
108
|
|
|
$template = (new BaseUITwigExtension())->bootstrapAlertDangerFunction($args); |
109
|
|
|
$searches = ["alert-danger"]; |
110
|
|
|
$replaces = [$this->getColor(ArrayUtility::get($args, "color", "red"), "bg-")]; |
111
|
|
|
return StringUtility::replace($template, $searches, $replaces); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |
115
|
|
|
|