Skip to content

Commit 8ac9631

Browse files
committed
refactor: require bool of fields
remove dead code for fields Signed-off-by: Thierry Bugier <[email protected]>
1 parent 3b87058 commit 8ac9631

23 files changed

+44
-276
lines changed

inc/fieldinterface.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface PluginFormcreatorFieldInterface
4141
*/
4242
public static function getName();
4343

44-
public static function getPrefs();
44+
public static function canRequire();
4545

4646
/**
4747
* Are the prerequisites met to use this field ?

inc/fields/actorfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,8 @@ public function isValid() {
238238
return true;
239239
}
240240

241-
public static function getPrefs() {
242-
return [
243-
'required' => 1,
244-
'default_values' => 1,
245-
'values' => 0,
246-
'range' => 0,
247-
'show_empty' => 0,
248-
'regex' => 0,
249-
'show_type' => 0,
250-
'dropdown_value' => 0,
251-
'glpi_objects' => 0,
252-
'ldap_values' => 0,
253-
];
241+
public static function canRequire() {
242+
return true;
254243
}
255244

256245
public function prepareQuestionInputForSave($input) {

inc/fields/checkboxesfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,8 @@ public function getDocumentsForTarget() {
265265
return [];
266266
}
267267

268-
public static function getPrefs() {
269-
return [
270-
'required' => 1,
271-
'default_values' => 1,
272-
'values' => 1,
273-
'range' => 1,
274-
'show_empty' => 0,
275-
'regex' => 0,
276-
'show_type' => 1,
277-
'dropdown_value' => 0,
278-
'glpi_objects' => 0,
279-
'ldap_values' => 0,
280-
];
268+
public static function canRequire() {
269+
return true;
281270
}
282271

283272
public function getEmptyParameters() {

inc/fields/datefield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,8 @@ public static function getName() {
9494
return __('Date');
9595
}
9696

97-
public static function getPrefs() {
98-
return [
99-
'required' => 1,
100-
'default_values' => 0,
101-
'values' => 0,
102-
'range' => 0,
103-
'show_empty' => 0,
104-
'regex' => 0,
105-
'show_type' => 1,
106-
'dropdown_value' => 0,
107-
'glpi_objects' => 0,
108-
'ldap_values' => 0,
109-
];
97+
public static function canRequire() {
98+
return true;
11099
}
111100

112101
public function equals($value) {

inc/fields/datetimefield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,8 @@ public static function getName() {
9797
return __('Date & time', 'formcreator');
9898
}
9999

100-
public static function getPrefs() {
101-
return [
102-
'required' => 1,
103-
'default_values' => 0,
104-
'values' => 0,
105-
'range' => 0,
106-
'show_empty' => 0,
107-
'regex' => 0,
108-
'show_type' => 1,
109-
'dropdown_value' => 0,
110-
'glpi_objects' => 0,
111-
'ldap_values' => 0,
112-
];
100+
public static function canRequire() {
101+
return true;
113102
}
114103

115104
public function equals($value) {

inc/fields/descriptionfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,8 @@ public function prepareQuestionInputForSave($input) {
100100
return $input;
101101
}
102102

103-
public static function getPrefs() {
104-
return [
105-
'required' => 0,
106-
'default_values' => 0,
107-
'values' => 0,
108-
'range' => 0,
109-
'show_empty' => 0,
110-
'regex' => 0,
111-
'show_type' => 1,
112-
'dropdown_value' => 0,
113-
'glpi_objects' => 0,
114-
'ldap_values' => 0,
115-
];
103+
public static function canRequire() {
104+
return false;
116105
}
117106

118107
public function equals($value) {

inc/fields/dropdownfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,8 @@ public function prepareQuestionInputForSave($input) {
424424
return $input;
425425
}
426426

427-
public static function getPrefs() {
428-
return [
429-
'required' => 1,
430-
'default_values' => 0,
431-
'values' => 0,
432-
'range' => 0,
433-
'show_empty' => 1,
434-
'regex' => 0,
435-
'show_type' => 1,
436-
'dropdown_value' => 1,
437-
'glpi_objects' => 0,
438-
'ldap_values' => 0,
439-
];
427+
public static function canRequire() {
428+
return true;
440429
}
441430

442431
/**

inc/fields/emailfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,8 @@ public static function getName() {
110110
return _n('Email', 'Emails', 1);
111111
}
112112

113-
public static function getPrefs() {
114-
return [
115-
'required' => 1,
116-
'default_values' => 0,
117-
'values' => 0,
118-
'range' => 0,
119-
'show_empty' => 0,
120-
'regex' => 0,
121-
'show_type' => 1,
122-
'dropdown_value' => 0,
123-
'glpi_objects' => 0,
124-
'ldap_values' => 0,
125-
];
113+
public static function canRequire() {
114+
return true;
126115
}
127116

128117
public function prepareQuestionInputForSave($input) {

inc/fields/filefield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,8 @@ public static function getName() {
109109
return __('File');
110110
}
111111

112-
public static function getPrefs() {
113-
return [
114-
'required' => 1,
115-
'default_values' => 0,
116-
'values' => 0,
117-
'range' => 0,
118-
'show_empty' => 0,
119-
'regex' => 0,
120-
'show_type' => 1,
121-
'dropdown_value' => 0,
122-
'glpi_objects' => 0,
123-
'ldap_values' => 0,
124-
];
112+
public static function canRequire() {
113+
return true;
125114
}
126115

127116
/**

inc/fields/floatfield.class.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,8 @@ public function parseAnswerValues($input, $nonDestructive = false) {
220220
return true;
221221
}
222222

223-
public static function getPrefs() {
224-
return [
225-
'required' => 1,
226-
'default_values' => 1,
227-
'values' => 0,
228-
'range' => 1,
229-
'show_empty' => 0,
230-
'regex' => 1,
231-
'show_type' => 1,
232-
'dropdown_value' => 0,
233-
'glpi_objects' => 0,
234-
'ldap_values' => 0,
235-
];
223+
public static function canRequire() {
224+
return true;
236225
}
237226

238227
public function getEmptyParameters() {

0 commit comments

Comments
 (0)