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 WBW\Bundle\CoreBundle\Icon\MaterialDesignIconicFont\MaterialDesignIconicFontIconInterface; |
15
|
|
|
use WBW\Bundle\CoreBundle\Icon\MaterialDesignIconicFont\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\Plugin |
23
|
|
|
* @abstract |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractMaterialDesignIconicFontTwigExtension extends AbstractTwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Displays 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) { |
34
|
|
|
|
35
|
|
|
$attributes = []; |
36
|
|
|
|
37
|
|
|
$attributes["class"][] = "zmdi"; |
38
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon); |
39
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSize($icon); |
40
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon); |
41
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderBorder($icon); |
42
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderPull($icon); |
43
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSpin($icon); |
44
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderRotate($icon); |
45
|
|
|
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFlip($icon); |
46
|
|
|
$attributes["style"] = MaterialDesignIconicFontIconRenderer::renderStyle($icon); |
47
|
|
|
|
48
|
|
|
return static::coreHTMLElement("i", null, $attributes); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Displays a Material Design Iconic Font list. |
53
|
|
|
* |
54
|
|
|
* @param array|string $items The items. |
55
|
|
|
* @return string Returns the Material Design Iconic Font list. |
56
|
|
|
*/ |
57
|
|
|
protected function materialDesignIconicFontList($items) { |
58
|
|
|
|
59
|
|
|
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items; |
60
|
|
|
|
61
|
|
|
return static::coreHTMLElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Displays a Material Design Iconic Font list icon. |
66
|
|
|
* |
67
|
|
|
* @param string $icon The icon. |
68
|
|
|
* @param string $content The content. |
69
|
|
|
* @return string Returns the Material Design Iconic Font list icon. |
70
|
|
|
*/ |
71
|
|
|
protected function materialDesignIconicFontListIcon($icon, $content) { |
72
|
|
|
|
73
|
|
|
$glyphicon = null !== $icon ? str_replace(["class=\"zmdi"], ["class=\"zmdi-hc-li zmdi"], $icon) : ""; |
74
|
|
|
$innerHTML = null !== $content ? $content : ""; |
75
|
|
|
|
76
|
|
|
return static::coreHTMLElement("li", $glyphicon . $innerHTML); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|