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