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 factory. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\CoreBundle\Icon |
21
|
|
|
*/ |
22
|
|
|
class IconFactory { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Creates a Font Awesome icon. |
26
|
|
|
* |
27
|
|
|
* @return FontAwesomeIconInterface Returns the Font Awesome icon. |
28
|
|
|
*/ |
29
|
|
|
public static function newFontAwesomeIcon() { |
30
|
|
|
return new FontAwesomeIcon(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Creates a Material Design Iconic Font icon |
35
|
|
|
* |
36
|
|
|
* @return MaterialDesignIconicFontIconInterface Returns the Material Design Iconic Font icon. |
37
|
|
|
*/ |
38
|
|
|
public static function newMaterialDesignIconicFontIcon() { |
39
|
|
|
return new MaterialDesignIconicFontIcon(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Parses a Font Awesome icon. |
44
|
|
|
* |
45
|
|
|
* @param array $args The arguments. |
46
|
|
|
* @return FontAwesomeIconInterface Returns the parsed Font Awesome icon. |
47
|
|
|
*/ |
48
|
|
|
public static function parseFontAwesomeIcon(array $args) { |
49
|
|
|
|
50
|
|
|
// Initialize the icon. |
51
|
|
|
$icon = static::newFontAwesomeIcon(); |
52
|
|
|
|
53
|
|
|
$icon->setName(ArrayHelper::get($args, "name", "home")); |
54
|
|
|
$icon->setStyle(ArrayHelper::get($args, "style")); |
55
|
|
|
|
56
|
|
|
$icon->setAnimation(ArrayHelper::get($args, "animation")); |
57
|
|
|
$icon->setBordered(ArrayHelper::get($args, "bordered", false)); |
58
|
|
|
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false)); |
59
|
|
|
$icon->setFont(ArrayHelper::get($args, "font")); |
60
|
|
|
$icon->setPull(ArrayHelper::get($args, "pull")); |
61
|
|
|
$icon->setSize(ArrayHelper::get($args, "size")); |
62
|
|
|
|
63
|
|
|
// Return the icon. |
64
|
|
|
return $icon; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Parses a Material Design Iconic Font icon. |
69
|
|
|
* |
70
|
|
|
* @param array $args The arguments. |
71
|
|
|
* @return MaterialDesignIconicFontIconInterface Returns the parsed Material Design Iconic Font icon. |
72
|
|
|
*/ |
73
|
|
|
public static function parseMaterialDesignIconicFontIcon(array $args) { |
74
|
|
|
|
75
|
|
|
// Initialize the icon. |
76
|
|
|
$icon = static::newMaterialDesignIconicFontIcon(); |
77
|
|
|
|
78
|
|
|
$icon->setName(ArrayHelper::get($args, "name", "home")); |
79
|
|
|
$icon->setStyle(ArrayHelper::get($args, "style")); |
80
|
|
|
|
81
|
|
|
$icon->setBorder(ArrayHelper::get($args, "border", false)); |
82
|
|
|
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false)); |
83
|
|
|
$icon->setFlip(ArrayHelper::get($args, "flip")); |
84
|
|
|
$icon->setPull(ArrayHelper::get($args, "pull")); |
85
|
|
|
$icon->setRotate(ArrayHelper::get($args, "rotate")); |
86
|
|
|
$icon->setSize(ArrayHelper::get($args, "size")); |
87
|
|
|
$icon->setSpin(ArrayHelper::get($args, "spin")); |
88
|
|
|
|
89
|
|
|
// Return the icon. |
90
|
|
|
return $icon; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|