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\FontAwesome\FontAwesomeIconInterface; |
15
|
|
|
use WBW\Bundle\CoreBundle\Icon\FontAwesome\FontAwesomeIconRenderer; |
16
|
|
|
use WBW\Bundle\CoreBundle\Twig\Extension\AbstractTwigExtension; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Abstract Font Awesome Twig extension. |
20
|
|
|
* |
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
22
|
|
|
* @package WBW\Bundle\CoreBundle\Twig\Extension\Asset |
23
|
|
|
* @abstract |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractFontAwesomeTwigExtension extends AbstractTwigExtension { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Displays a Font Awesome icon. |
29
|
|
|
* |
30
|
|
|
* @param FontAwesomeIconInterface $icon The icon. |
31
|
|
|
* @return string Returns the Font Awesome icon. |
32
|
|
|
*/ |
33
|
|
|
protected function fontAwesomeIcon(FontAwesomeIconInterface $icon) { |
34
|
|
|
|
35
|
|
|
$attributes = []; |
36
|
|
|
|
37
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderFont($icon); |
38
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderName($icon); |
39
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderSize($icon); |
40
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderFixedWidth($icon); |
41
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderBordered($icon); |
42
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderPull($icon); |
43
|
|
|
$attributes["class"][] = FontAwesomeIconRenderer::renderAnimation($icon); |
44
|
|
|
$attributes["style"] = FontAwesomeIconRenderer::renderStyle($icon); |
45
|
|
|
|
46
|
|
|
return static::coreHTMLElement("i", null, $attributes); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Displays a Font Awesome list. |
51
|
|
|
* |
52
|
|
|
* @param array|string $items The items. |
53
|
|
|
* @return string Returns the Font Awesome list. |
54
|
|
|
*/ |
55
|
|
|
protected function fontAwesomeList($items) { |
56
|
|
|
|
57
|
|
|
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items; |
58
|
|
|
|
59
|
|
|
return static::coreHTMLElement("ul", $innerHTML, ["class" => "fa-ul"]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Displays a Font Awesome list icon. |
64
|
|
|
* |
65
|
|
|
* @param string $icon The icon. |
66
|
|
|
* @param string $content The content. |
67
|
|
|
* @return string Returns the Font Awesome list icon. |
68
|
|
|
*/ |
69
|
|
|
protected function fontAwesomeListIcon($icon, $content) { |
70
|
|
|
|
71
|
|
|
$glyphicon = static::coreHTMLElement("span", $icon, ["class" => "fa-li"]); |
72
|
|
|
$innerHTML = null !== $content ? $content : ""; |
73
|
|
|
|
74
|
|
|
return static::coreHTMLElement("li", $glyphicon . $innerHTML); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|