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\AlertComponentTwigExtension as BaseUITwigExtension; |
17
|
|
|
use WBW\Library\Core\Utility\Argument\ArrayUtility; |
18
|
|
|
use WBW\Library\Core\Utility\Argument\StringUtility; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Alert UI Twig extension. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb/> |
24
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI |
25
|
|
|
*/ |
26
|
|
|
class AlertUITwigExtension extends BaseUITwigExtension { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Service name. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
const SERVICE_NAME = "webeweb.bundle.adminbsbbundle.twig.extension.ui.alert"; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get the Twig functions. |
37
|
|
|
* |
38
|
|
|
* @return array Returns the Twig functions. |
39
|
|
|
*/ |
40
|
|
|
public function getFunctions() { |
41
|
|
|
return [ |
42
|
|
|
new Twig_SimpleFunction("adminBSBBasicAlertDanger", [$this, "bootstrapBasicAlertDangerFunction"], ["is_safe" => ["html"]]), |
43
|
|
|
new Twig_SimpleFunction("adminBSBBasicAlertInfo", [$this, "bootstrapBasicAlertInfoFunction"], ["is_safe" => ["html"]]), |
44
|
|
|
new Twig_SimpleFunction("adminBSBBasicAlertSuccess", [$this, "bootstrapBasicAlertSuccessFunction"], ["is_safe" => ["html"]]), |
45
|
|
|
new Twig_SimpleFunction("adminBSBBasicAlertWarning", [$this, "bootstrapBasicAlertWarningFunction"], ["is_safe" => ["html"]]), |
46
|
|
|
new Twig_SimpleFunction("adminBSBLinkAlert", [$this, "bootstrapLinkAlertFunction"], ["is_safe" => ["html"]]), |
47
|
|
|
new Twig_SimpleFunction("adminBSBMaterialDesignAlert", [$this, "adminBSBMaterialDesignAlertFunction"], ["is_safe" => ["html"]]), |
48
|
|
|
]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Displays an AdminBSB material design alert. |
53
|
|
|
* |
54
|
|
|
* @param array $args The arguments. |
55
|
|
|
* @return string Returns the AdminBSB material design alert. |
56
|
|
|
*/ |
57
|
|
|
public function adminBSBMaterialDesignAlertFunction(array $args = []) { |
58
|
|
|
$template = $this->bootstrapAlertDangerFunction($args); |
59
|
|
|
$searches = ["alert-danger"]; |
60
|
|
|
$replaces = [AbstractABSBMDTwigExtension::fixColor(ArrayUtility::get($args, "color", "red"), "bg-")]; |
61
|
|
|
return StringUtility::replace($template, $searches, $replaces); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|