|
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\Assets; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Assets\Icon\MaterialDesignIconicFontIconInterface; |
|
15
|
|
|
use WBW\Bundle\CoreBundle\Renderer\Assets\MaterialDesignIconicFontIconRenderer; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\Twig\Extension\AbstractTwigExtension; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Abstract Material Design Iconic Font Twig extension. |
|
20
|
|
|
* |
|
21
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
22
|
|
|
* @package WBW\Bundle\Core\Twig\Extension\Assets |
|
23
|
|
|
* @abstract |
|
24
|
|
|
*/ |
|
25
|
|
|
abstract class AbstractMaterialDesignIconicFontTwigExtension extends AbstractTwigExtension { |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Display a Material Design Iconic Font icon. |
|
29
|
|
|
* |
|
30
|
|
|
* @param MaterialDesignIconicFontIconInterface $icon The icon. |
|
31
|
|
|
* @return string Returns the Material Design Iconic Font icon. |
|
32
|
|
|
*/ |
|
33
|
|
|
protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon): string { |
|
34
|
|
|
|
|
35
|
|
|
$attributes = [ |
|
36
|
|
|
"class" => [ |
|
37
|
|
|
"zmdi", |
|
38
|
|
|
MaterialDesignIconicFontIconRenderer::renderName($icon), |
|
39
|
|
|
MaterialDesignIconicFontIconRenderer::renderSize($icon), |
|
40
|
|
|
MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon), |
|
41
|
|
|
MaterialDesignIconicFontIconRenderer::renderBorder($icon), |
|
42
|
|
|
MaterialDesignIconicFontIconRenderer::renderPull($icon), |
|
43
|
|
|
MaterialDesignIconicFontIconRenderer::renderSpin($icon), |
|
44
|
|
|
MaterialDesignIconicFontIconRenderer::renderRotate($icon), |
|
45
|
|
|
MaterialDesignIconicFontIconRenderer::renderFlip($icon), |
|
46
|
|
|
], |
|
47
|
|
|
"style" => MaterialDesignIconicFontIconRenderer::renderStyle($icon), |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
return static::coreHtmlElement("i", null, $attributes); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Display a Material Design Iconic Font list. |
|
55
|
|
|
* |
|
56
|
|
|
* @param array|string $items The items. |
|
57
|
|
|
* @return string Returns the Material Design Iconic Font list. |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function materialDesignIconicFontList($items): string { |
|
60
|
|
|
|
|
61
|
|
|
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items; |
|
62
|
|
|
|
|
63
|
|
|
return static::coreHtmlElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Display a Material Design Iconic Font list icon. |
|
68
|
|
|
* |
|
69
|
|
|
* @param string|null $icon The icon. |
|
70
|
|
|
* @param string|null $content The content. |
|
71
|
|
|
* @return string Returns the Material Design Iconic Font list icon. |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function materialDesignIconicFontListIcon(?string $icon, ?string $content): string { |
|
74
|
|
|
|
|
75
|
|
|
$glyphicon = null !== $icon ? str_replace(['class="zmdi'], ['class="zmdi-hc-li zmdi'], $icon) : ""; |
|
76
|
|
|
$innerHTML = null !== $content ? $content : ""; |
|
77
|
|
|
|
|
78
|
|
|
return static::coreHtmlElement("li", $glyphicon . $innerHTML); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|