1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 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\Icon; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Core\Argument\ArrayHelper; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Icon parser. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\CoreBundle\Icon |
21
|
|
|
*/ |
22
|
|
|
class IconParser { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Parses a Font Awesome icon. |
26
|
|
|
* |
27
|
|
|
* @param array $args The arguments. |
28
|
|
|
* @return FontAwesomeIconInterface Returns the parsed Font Awesome icon. |
29
|
|
|
*/ |
30
|
|
|
public static function parseFontAwesomeIcon(array $args) { |
31
|
|
|
|
32
|
|
|
// Initialize the icon. |
33
|
|
|
$icon = IconFactory::newFontAwesomeIcon(); |
34
|
|
|
|
35
|
|
|
$icon->setName(ArrayHelper::get($args, "name", "home")); |
36
|
|
|
$icon->setStyle(ArrayHelper::get($args, "style")); |
37
|
|
|
|
38
|
|
|
$icon->setAnimation(ArrayHelper::get($args, "animation")); |
39
|
|
|
$icon->setBordered(ArrayHelper::get($args, "bordered", false)); |
40
|
|
|
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false)); |
41
|
|
|
$icon->setFont(ArrayHelper::get($args, "font")); |
42
|
|
|
$icon->setPull(ArrayHelper::get($args, "pull")); |
43
|
|
|
$icon->setSize(ArrayHelper::get($args, "size")); |
44
|
|
|
|
45
|
|
|
// Return the icon. |
46
|
|
|
return $icon; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Parses a Material Design Iconic Font icon. |
51
|
|
|
* |
52
|
|
|
* @param array $args The arguments. |
53
|
|
|
* @return MaterialDesignIconicFontIconInterface Returns the parsed Material Design Iconic Font icon. |
54
|
|
|
*/ |
55
|
|
|
public static function parseMaterialDesignIconicFontIcon(array $args) { |
56
|
|
|
|
57
|
|
|
// Initialize the icon. |
58
|
|
|
$icon = IconFactory::newMaterialDesignIconicFontIcon(); |
59
|
|
|
|
60
|
|
|
$icon->setName(ArrayHelper::get($args, "name", "home")); |
61
|
|
|
$icon->setStyle(ArrayHelper::get($args, "style")); |
62
|
|
|
|
63
|
|
|
$icon->setBorder(ArrayHelper::get($args, "border", false)); |
64
|
|
|
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false)); |
65
|
|
|
$icon->setFlip(ArrayHelper::get($args, "flip")); |
66
|
|
|
$icon->setPull(ArrayHelper::get($args, "pull")); |
67
|
|
|
$icon->setRotate(ArrayHelper::get($args, "rotate")); |
68
|
|
|
$icon->setSize(ArrayHelper::get($args, "size")); |
69
|
|
|
$icon->setSpin(ArrayHelper::get($args, "spin")); |
70
|
|
|
|
71
|
|
|
// Return the icon. |
72
|
|
|
return $icon; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
|