1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sco\Admin\Form\Elements; |
4
|
|
|
|
5
|
|
|
class ElSwitch extends NamedElement |
6
|
|
|
{ |
7
|
|
|
protected $type = 'elswitch'; |
8
|
|
|
|
9
|
|
|
protected $texts = ['ON', 'OFF']; |
10
|
|
|
protected $values = ['yes', 'no']; |
11
|
|
|
protected $colors = []; |
12
|
|
|
protected $iconClasses = []; |
13
|
|
|
|
14
|
|
|
protected $width = 40; |
15
|
|
|
|
16
|
|
|
public function getWidth() |
17
|
|
|
{ |
18
|
|
|
return $this->width; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function setWidth($value) |
22
|
|
|
{ |
23
|
|
|
$this->width = intval($value); |
24
|
|
|
|
25
|
|
|
return $this; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getValues() |
29
|
|
|
{ |
30
|
|
|
return $this->values; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param $active |
35
|
|
|
* @param $inactive |
36
|
|
|
* |
37
|
|
|
* @return ElSwitch |
38
|
|
|
*/ |
39
|
|
|
public function setValues($active, $inactive) |
40
|
|
|
{ |
41
|
|
|
$this->values = [$active, $inactive]; |
42
|
|
|
|
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getTexts() |
47
|
|
|
{ |
48
|
|
|
return $this->texts; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param $active |
53
|
|
|
* @param $inactive |
54
|
|
|
* |
55
|
|
|
* @return ElSwitch |
56
|
|
|
*/ |
57
|
|
|
public function setTexts($active, $inactive) |
58
|
|
|
{ |
59
|
|
|
$this->texts = [$active, $inactive]; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getColors() |
65
|
|
|
{ |
66
|
|
|
return $this->colors; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param $active |
71
|
|
|
* @param $inactive |
72
|
|
|
* |
73
|
|
|
* @return ElSwitch |
74
|
|
|
*/ |
75
|
|
|
public function setColors($active, $inactive) |
76
|
|
|
{ |
77
|
|
|
$this->colors = [$active, $inactive]; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getIconClasses() |
83
|
|
|
{ |
84
|
|
|
return $this->iconClasses; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function setIconClasses($active, $inactive) |
88
|
|
|
{ |
89
|
|
|
$this->iconClasses = [$active, $inactive]; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function toArray() |
95
|
|
|
{ |
96
|
|
|
return parent::toArray() + [ |
97
|
|
|
'texts' => $this->getTexts(), |
98
|
|
|
'values' => $this->getValues(), |
99
|
|
|
'colors' => $this->getColors(), |
100
|
|
|
'iconClasses' => $this->getIconClasses(), |
101
|
|
|
'width' => $this->getWidth(), |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|