Skip to content

Commit 82548ab

Browse files
committed
chore: create methods with fields as certification.js
Signed-off-by: Crisciany Souza <[email protected]>
1 parent 8ca803f commit 82548ab

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

lib/Service/Certificate/RulesService.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,40 @@ public function getRule(string $fieldName): array {
5959
public function getHelperText(string $fieldName): ?string {
6060
return match ($fieldName) {
6161
'CN' => $this->l10n->t('Common Name (CN)'),
62-
'C' => $this->l10n->t('Two-letter ISO 3166 country code'),
62+
'C' => $tcertificate/his->l10n->t('Two-letter ISO 3166 country code'),
6363
'ST' => $this->l10n->t('Full name of states or provinces'),
6464
'L' => $this->l10n->t('Name of a locality or place, such as a city, county, or other geographic region'),
6565
'O' => $this->l10n->t('Name of an organization'),
6666
'OU' => $this->l10n->t('Name of an organizational unit'),
6767
default => null,
6868
};
6969
}
70+
71+
public function getAllRules(): array {
72+
$result = [];
73+
foreach ($this->rules as $field => $rule) {
74+
$result[] = [
75+
'id' => $field,
76+
'label' => $this->getLabel($field),
77+
'min' => $rule['min'] ?? null,
78+
'max' => $rule['max'] ?? null,
79+
'required' => $rule['required'] ?? false,
80+
'helperText' => $this->getHelperText($field),
81+
];
82+
}
83+
return $result;
84+
}
85+
86+
private function getLabel(string $fieldName): string {
87+
return match ($fieldName) {
88+
'CN' => $this->l10n->t('Common Name (CN)'),
89+
'C' => $this->l10n->t('Country'),
90+
'ST' => $this->l10n->t('State'),
91+
'L' => $this->l10n->t('Locality'),
92+
'O' => $this->l10n->t('Organization'),
93+
'OU' => $this->l10n->t('Organizational Unit'),
94+
default => $fieldName,
95+
};
96+
}
97+
7098
}

0 commit comments

Comments
 (0)