-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathSharedConfigurationFormFields.class.php
More file actions
93 lines (84 loc) · 3.16 KB
/
SharedConfigurationFormFields.class.php
File metadata and controls
93 lines (84 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace wcf\system\form\option;
use wcf\event\form\option\SharedConfigurationFormFieldCollecting;
use wcf\system\event\EventHandler;
use wcf\system\form\builder\field\BooleanFormField;
use wcf\system\form\builder\field\FloatFormField;
use wcf\system\form\builder\field\IFormField;
use wcf\system\form\builder\field\IntegerFormField;
use wcf\system\form\builder\field\SelectOptionsFormField;
use wcf\system\form\builder\field\TextFormField;
/**
* Provides the available shared configuration form fields.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class SharedConfigurationFormFields
{
/**
* @var array<string, IFormField>
*/
private array $formFields;
public function __construct()
{
$this->formFields = \array_merge($this->getDefaultFormFields(), $this->getEventFormFields());
}
/**
* @return array<string, IFormField>
*/
private function getDefaultFormFields(): array
{
return [
'currency' => TextFormField::create('currency')
->label('wcf.form.option.shared.currency')
->value('EUR')
->addFieldClass('short')
->required(),
'defaultTextValue' => TextFormField::create('defaultTextValue')
->label('wcf.form.option.shared.defaultValue')
->addFieldClass('medium'),
'maxLength' => IntegerFormField::create('maxLength')
->label('wcf.form.option.shared.maxLength'),
'minIntegerValue' => IntegerFormField::create('minIntegerValue')
->label('wcf.form.option.shared.minValue'),
'maxIntegerValue' => IntegerFormField::create('maxIntegerValue')
->label('wcf.form.option.shared.maxValue'),
'minFloatValue' => FloatFormField::create('minFloatValue')
->label('wcf.form.option.shared.minValue'),
'maxFloatValue' => FloatFormField::create('maxFloatValue')
->label('wcf.form.option.shared.maxValue'),
'selectOptions' => SelectOptionsFormField::create('selectOptions')
->label('wcf.form.option.shared.selectOptions')
->required(),
'required' => BooleanFormField::create('required')
->label('wcf.form.option.shared.required')
->value(false),
'unit' => TextFormField::create('unit')
->label('wcf.form.option.shared.unit')
->addFieldClass('short')
];
}
/**
* @return array<string, IFormField>
*/
private function getEventFormFields(): array
{
$event = new SharedConfigurationFormFieldCollecting();
EventHandler::getInstance()->fire($event);
return $event->getFormFields();
}
/**
* @return array<string, IFormField>
*/
public function getFormFields(): array
{
return $this->formFields;
}
public function getFormField(string $identifier): ?IFormField
{
return $this->formFields[$identifier] ?? null;
}
}