1 | <?php |
||
55 | final class WidgetSetting implements JsonSerializable { |
||
56 | |||
57 | |||
58 | const TYPE_INPUT = 'input'; |
||
59 | const TYPE_CHECKBOX = 'checkbox'; |
||
60 | |||
61 | |||
62 | /** @var string */ |
||
63 | private $name = ''; |
||
64 | |||
65 | /** @var string */ |
||
66 | private $title = ''; |
||
67 | |||
68 | /** @var string */ |
||
69 | private $type = ''; |
||
70 | |||
71 | /** @var string */ |
||
72 | private $placeholder = ''; |
||
73 | |||
74 | /** @var string */ |
||
75 | private $default = ''; |
||
76 | |||
77 | |||
78 | /** |
||
79 | * WidgetSetting constructor. |
||
80 | * |
||
81 | * @since 15.0.0 |
||
82 | * |
||
83 | * @param string $type |
||
84 | */ |
||
85 | public function __construct(string $type = '') { |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Set the name of the setting (full string, no space) |
||
92 | * |
||
93 | * @since 15.0.0 |
||
94 | * |
||
95 | * @param string $name |
||
96 | * |
||
97 | * @return WidgetSetting |
||
98 | */ |
||
99 | public function setName(string $name): WidgetSetting { |
||
104 | |||
105 | /** |
||
106 | * Get the name of the setting |
||
107 | * |
||
108 | * @since 15.0.0 |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getName(): string { |
||
115 | |||
116 | |||
117 | /** |
||
118 | * Set the title/display name of the setting. |
||
119 | * |
||
120 | * @since 15.0.0 |
||
121 | * |
||
122 | * @param string $title |
||
123 | * |
||
124 | * @return WidgetSetting |
||
125 | */ |
||
126 | public function setTitle(string $title): WidgetSetting { |
||
131 | |||
132 | /** |
||
133 | * Get the title of the setting |
||
134 | * |
||
135 | * @since 15.0.0 |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getTitle(): string { |
||
142 | |||
143 | |||
144 | /** |
||
145 | * Set the type of the setting (input, checkbox, ...) |
||
146 | * |
||
147 | * @since 15.0.0 |
||
148 | * |
||
149 | * @param string $type |
||
150 | * |
||
151 | * @return WidgetSetting |
||
152 | */ |
||
153 | public function setType(string $type): WidgetSetting { |
||
158 | |||
159 | /** |
||
160 | * Get the type of the setting. |
||
161 | * |
||
162 | * @since 15.0.0 |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getType(): string { |
||
169 | |||
170 | |||
171 | /** |
||
172 | * Set the placeholder (in case of type=input) |
||
173 | * |
||
174 | * @since 15.0.0 |
||
175 | * |
||
176 | * @param string $text |
||
177 | * |
||
178 | * @return WidgetSetting |
||
179 | */ |
||
180 | public function setPlaceholder(string $text): WidgetSetting { |
||
185 | |||
186 | /** |
||
187 | * Get the placeholder. |
||
188 | * |
||
189 | * @since 15.0.0 |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | public function getPlaceholder(): string { |
||
196 | |||
197 | |||
198 | /** |
||
199 | * Set the default value of the setting. |
||
200 | * |
||
201 | * @since 15.0.0 |
||
202 | * |
||
203 | * @param string $value |
||
204 | * |
||
205 | * @return WidgetSetting |
||
206 | */ |
||
207 | public function setDefault(string $value): WidgetSetting { |
||
212 | |||
213 | /** |
||
214 | * Get the default value. |
||
215 | * |
||
216 | * @since 15.0.0 |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | public function getDefault(): string { |
||
223 | |||
224 | |||
225 | /** |
||
226 | * @since 15.0.0 |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | public function jsonSerialize() { |
||
239 | |||
240 | |||
241 | } |
||
242 | |||
243 |