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