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,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Communication;
|
||||
|
||||
/**
|
||||
* Die Beschreibung des Formulars für den Browser. Sie enthält, was zur Darstellung nötig ist (Texte, Schritte, Felder,
|
||||
* Auswahlwerte), und den ersten Zustand der Bedingungen, aber keine Regeln und keine Verwendungszwecke: Entscheidungen
|
||||
* über Sichtbarkeit und Pflicht trifft ausschließlich der Server (FormEvaluator).
|
||||
*/
|
||||
final class FormPayload
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $form wirksames Formular (FormFactory::effective)
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function definition(array $form, FormEvaluator $evaluator): array
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
foreach ((array) $form['fields'] as $key => $field) {
|
||||
$settings = (array) ($field['settings'] ?? []);
|
||||
$fields[$key] = array_filter([
|
||||
'key' => $key,
|
||||
'label' => $field['label'],
|
||||
'help' => $field['help'],
|
||||
'type' => $field['type'],
|
||||
'options' => $field['options'] ?: null,
|
||||
'max_length' => $settings['max_length'] ?? null,
|
||||
'min' => $settings['min'] ?? null,
|
||||
'max' => $settings['max'] ?? null,
|
||||
], fn (mixed $value): bool => $value !== null);
|
||||
}
|
||||
|
||||
return [
|
||||
'mode' => $form['mode'] ?? 'compact',
|
||||
'open' => $form['open'] ?? 'inline',
|
||||
'texts' => $form['texts'],
|
||||
'issues' => $form['issues'],
|
||||
'defaults' => (object) ($form['defaults'] ?? []),
|
||||
'controls' => $form['controls'] ?? [],
|
||||
'steps' => $form['steps'],
|
||||
'fields' => $fields,
|
||||
'state' => self::state($form, (array) ($form['defaults'] ?? []), $evaluator),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $form
|
||||
* @param array<string, mixed> $values
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function state(array $form, array $values, FormEvaluator $evaluator): array
|
||||
{
|
||||
$state = $evaluator->evaluate($form, $values);
|
||||
|
||||
return [
|
||||
'steps' => (object) $state['steps'],
|
||||
'groups' => (object) $state['groups'],
|
||||
'fields' => (object) $state['fields'],
|
||||
'required' => (object) $state['required'],
|
||||
'presets' => (object) $state['presets'],
|
||||
'issue' => $state['issue'],
|
||||
'subissue' => $state['subissue'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user