1 | <?php |
||
16 | class Stack |
||
17 | { |
||
18 | |||
19 | /** @var string */ |
||
20 | public static $defaultTag = 'span'; |
||
21 | |||
22 | /** @var string */ |
||
23 | private $tag; |
||
24 | |||
25 | /** @var array */ |
||
26 | private $options = []; |
||
27 | |||
28 | /** @var Icon */ |
||
29 | private $icon_front; |
||
30 | |||
31 | /** @var Icon */ |
||
32 | private $icon_back; |
||
33 | |||
34 | /** |
||
35 | * @param array $options |
||
36 | */ |
||
37 | 1 | public function __construct($options = []) |
|
38 | { |
||
39 | Html::addCssClass($options, 'fa-stack'); |
||
40 | |||
41 | 1 | $this->options = $options; |
|
42 | 1 | } |
|
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function __toString() |
||
51 | |||
52 | /** |
||
53 | * @param string|Icon $icon |
||
54 | * @param array $options |
||
55 | * @return self |
||
56 | */ |
||
57 | public function icon($icon, $options = []) |
||
58 | { |
||
59 | if (is_string($icon)) { |
||
60 | $icon = new Icon($icon, $options); |
||
61 | } |
||
62 | |||
63 | $this->icon_front = $icon; |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param string|Icon $icon |
||
70 | * @param array $options |
||
71 | * @return self |
||
72 | */ |
||
73 | public function on($icon, $options = []) |
||
74 | { |
||
75 | if (is_string($icon)) { |
||
76 | $icon = new Icon($icon, $options); |
||
77 | } |
||
78 | |||
79 | $this->icon_back = $icon; |
||
80 | |||
81 | return $this; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Change html tag. |
||
86 | * @param string $tag |
||
87 | * @return static |
||
88 | * @throws \yii\base\InvalidParamException |
||
89 | */ |
||
90 | 1 | public function tag($tag) |
|
96 | |||
97 | /** |
||
98 | * @param string|null $tag |
||
99 | * @param array $options |
||
100 | * @return string |
||
101 | * @throws \yii\base\InvalidConfigException |
||
102 | */ |
||
103 | public function render($tag = null, $options = []) |
||
125 | } |