Baue die Verwaltung Kommunikation, die öffentliche Anfrageschnittstelle und das CMS-Widget Anfrage
Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen mit Fassungen, Anfrage-Einstiege, Posteingang mit Status und Notizen, Einstellungen mit Empfängern. Das Widget speichert nur die Kennung eines veröffentlichten Einstiegs; Formular, Bedingungen und Annahme kommen zur Laufzeit vom Server (Kompaktformular und mehrstufiger Dialog aus derselben Beschreibung). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ee1fc9866
commit
c6a8167601
45 files changed
+5415
No files matched your search
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Communication;
|
||||
|
||||
/**
|
||||
* Bereinigt den Entwurf einer Anfragevorlage aus dem Formular der Verwaltung: Listen mit fortlaufenden Schlüsseln
|
||||
* (Repeater liefern Zufallsschlüssel), nur bekannte Felder, Texte begrenzt. Eine inhaltliche Prüfung geschieht erst beim
|
||||
* Veröffentlichen (TemplateCompiler); ein unfertiger Entwurf darf gespeichert werden.
|
||||
*/
|
||||
final class TemplateDraft
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $draft
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function clean(array $draft): array
|
||||
{
|
||||
$steps = [];
|
||||
|
||||
foreach (array_values((array) ($draft['steps'] ?? [])) as $step) {
|
||||
$step = is_array($step) ? $step : [];
|
||||
$items = [];
|
||||
|
||||
foreach (array_values((array) ($step['items'] ?? [])) as $item) {
|
||||
$item = is_array($item) ? $item : [];
|
||||
$kind = (string) ($item['kind'] ?? '');
|
||||
|
||||
$items[] = match ($kind) {
|
||||
'issue' => ['kind' => 'issue'],
|
||||
'group' => ['kind' => 'group', 'group' => (string) ($item['group'] ?? '')],
|
||||
'field' => ['kind' => 'field', 'field' => (string) ($item['field'] ?? ''), 'required' => (bool) ($item['required'] ?? false)],
|
||||
default => ['kind' => $kind],
|
||||
};
|
||||
}
|
||||
|
||||
$steps[] = [
|
||||
'key' => (string) ($step['key'] ?? ''),
|
||||
'title' => mb_substr(trim((string) ($step['title'] ?? '')), 0, 120),
|
||||
'intro' => filled($step['intro'] ?? null) ? mb_substr(trim((string) $step['intro']), 0, 600) : null,
|
||||
'items' => $items,
|
||||
];
|
||||
}
|
||||
|
||||
$rules = [];
|
||||
|
||||
foreach (array_values((array) ($draft['rules'] ?? [])) as $rule) {
|
||||
$rule = is_array($rule) ? $rule : [];
|
||||
$conditions = [];
|
||||
|
||||
foreach (array_values((array) ($rule['conditions'] ?? [])) as $condition) {
|
||||
$condition = is_array($condition) ? $condition : [];
|
||||
$conditions[] = [
|
||||
'source' => (string) ($condition['source'] ?? ''),
|
||||
'op' => (string) ($condition['op'] ?? 'eq'),
|
||||
'values' => array_values(array_filter((array) ($condition['values'] ?? []), 'is_string')),
|
||||
];
|
||||
}
|
||||
|
||||
$rules[] = [
|
||||
'effect' => (string) ($rule['effect'] ?? ''),
|
||||
'target' => (string) ($rule['target'] ?? ''),
|
||||
'match' => ($rule['match'] ?? 'all') === 'any' ? 'any' : 'all',
|
||||
'conditions' => $conditions,
|
||||
'value' => filled($rule['value'] ?? null) ? (string) $rule['value'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'texts' => FormTexts::clean((array) ($draft['texts'] ?? [])),
|
||||
'issues' => array_values(array_filter((array) ($draft['issues'] ?? []), 'is_string')),
|
||||
'steps' => $steps,
|
||||
'rules' => $rules,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user