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\AbstractAdminBSBTwigExtension; |
16
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\IconRendererTwigExtensionInterface; |
17
|
|
|
use WBW\Library\Core\Utility\Argument\ArrayUtility; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Icon Twig extension. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI |
24
|
|
|
*/ |
25
|
|
|
class IconTwigExtension extends AbstractIconTwigExtension implements IconRendererTwigExtensionInterface { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Service name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
const SERVICE_NAME = "webeweb.adminbsbbundle.twig.extension.ui.icon"; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor. |
36
|
|
|
*/ |
37
|
|
|
public function __construct() { |
38
|
|
|
parent::__construct(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Displays an AdminBSB basic icon. |
43
|
|
|
* |
44
|
|
|
* @param array $args The arguments. |
45
|
|
|
* @return string Returns the AdminBSB basic icon. |
46
|
|
|
*/ |
47
|
|
|
public function adminBSBIconBasicFunction(array $args = []) { |
48
|
|
|
return $this->adminBSBIcon(ArrayUtility::get($args, "name"), ArrayUtility::get($args, "style")); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Displays an AdminBSB material design icon. |
53
|
|
|
* |
54
|
|
|
* @param array $args The arguments. |
55
|
|
|
* @return string Returns the AdminBSB material design icon. |
56
|
|
|
*/ |
57
|
|
|
public function adminBSBIconMaterialDesignFunction(array $args = []) { |
58
|
|
|
return $this->adminBSBIcon(ArrayUtility::get($args, "name"), ArrayUtility::get($args, "style"), AbstractAdminBSBTwigExtension::fixColor(ArrayUtility::get($args, "color"), "col-")); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the Twig functions. |
63
|
|
|
* |
64
|
|
|
* @return array Returns the Twig functions. |
65
|
|
|
*/ |
66
|
|
|
public function getFunctions() { |
67
|
|
|
return [ |
68
|
|
|
new Twig_SimpleFunction("adminBSBIconBasic", [$this, "adminBSBIconBasicFunction"], ["is_safe" => ["html"]]), |
69
|
|
|
new Twig_SimpleFunction("adminBSBIconMaterialDesign", [$this, "adminBSBIconMaterialDesignFunction"], ["is_safe" => ["html"]]), |
70
|
|
|
]; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritdoc} |
75
|
|
|
*/ |
76
|
|
|
public function renderIcon($name, $style) { |
77
|
|
|
return $this->adminBSBIconBasicFunction(["name" => $name, "style" => $style]); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|