1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-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\CoreBundle\Twig\Extension\Asset; |
13
|
|
|
|
14
|
|
|
use Twig\TwigFilter; |
15
|
|
|
use Twig\TwigFunction; |
16
|
|
|
use WBW\Bundle\CoreBundle\Icon\IconFactory; |
17
|
|
|
use WBW\Bundle\CoreBundle\Renderer\IconRendererInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Material Design Iconic Font Twig extension. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\CoreBundle\Twig\Extension\Asset |
24
|
|
|
*/ |
25
|
|
|
class MaterialDesignIconicFontTwigExtension extends AbstractMaterialDesignIconicFontTwigExtension implements IconRendererInterface { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Service name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
const SERVICE_NAME = "wbw.core.twig.extension.asset.material_design_iconic_font"; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get the Twig filters. |
36
|
|
|
* |
37
|
|
|
* @return TwigFilter[] Returns the Twig filters. |
38
|
|
|
*/ |
39
|
|
|
public function getFilters() { |
40
|
|
|
return [ |
41
|
|
|
new TwigFilter("materialDesignIconicFontList", [$this, "materialDesignIconicFontListFilter"], ["is_safe" => ["html"]]), |
42
|
|
|
new TwigFilter("mdiFontList", [$this, "materialDesignIconicFontListFilter"], ["is_safe" => ["html"]]), |
43
|
|
|
|
44
|
|
|
new TwigFilter("materialDesignIconicFontListIcon", [$this, "materialDesignIconicFontListIconFilter"], ["is_safe" => ["html"]]), |
45
|
|
|
new TwigFilter("mdiFontListIcon", [$this, "materialDesignIconicFontListIconFilter"], ["is_safe" => ["html"]]), |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get the Twig functions. |
51
|
|
|
* |
52
|
|
|
* @return TwigFunction[] Returns the Twig functions. |
53
|
|
|
*/ |
54
|
|
|
public function getFunctions() { |
55
|
|
|
return [ |
56
|
|
|
new TwigFunction("materialDesignIconicFontIcon", [$this, "materialDesignIconicFontIconFunction"], ["is_safe" => ["html"]]), |
57
|
|
|
new TwigFunction("mdiIcon", [$this, "materialDesignIconicFontIconFunction"], ["is_safe" => ["html"]]), |
58
|
|
|
]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Displays a Material Design Iconic Font icon. |
63
|
|
|
* |
64
|
|
|
* @param array $args The arguments. |
65
|
|
|
* @return string Returns the Material Design Iconic Font icon. |
66
|
|
|
*/ |
67
|
|
|
public function materialDesignIconicFontIconFunction(array $args = []) { |
68
|
|
|
return $this->materialDesignIconicFontIcon(IconFactory::parseMaterialDesignIconicFontIcon($args)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Displays a Material Design Iconic Font list. |
73
|
|
|
* |
74
|
|
|
* @param array|string $items The items. |
75
|
|
|
* @return string Returns the Material Design Iconic Font list. |
76
|
|
|
*/ |
77
|
|
|
public function materialDesignIconicFontListFilter($items) { |
78
|
|
|
return $this->materialDesignIconicFontList($items); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Displays a Material Design Iconic Font list icon. |
83
|
|
|
* |
84
|
|
|
* @param string $icon The icon. |
85
|
|
|
* @param string $content The content. |
86
|
|
|
* @return string Returns the Material Design Iconic Font list icon. |
87
|
|
|
*/ |
88
|
|
|
public function materialDesignIconicFontListIconFilter($icon, $content) { |
89
|
|
|
return $this->materialDesignIconicFontListIcon($icon, $content); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritDoc} |
94
|
|
|
*/ |
95
|
|
|
public function renderIcon($name, $style) { |
96
|
|
|
return $this->materialDesignIconicFontIconFunction(["name" => $name, "style" => $style]); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|