U-C: Kanalkonfigurator (Kanal › Ablauf): Modellwahl nach Kanalprofil (E2/O2), Schritte mit Schalter, Ausführung, Ausführenden und Fristen, Herkunft der Werte, Vorschau; ConfigureChannelProcess; Modell legt Einstellungen fest

Flache Prozessfelder im Kanalformular entfallen als Hauptansicht. Volle Suite 820/820.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-04 15:04:28 +01:00
1 parent d695566a7a
commit c255783cec
13 files changed
+981 -50

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
<?php
namespace App\Actions;
use App\Enums\IntakeKind;
use App\Enums\ProcessSetting;
use App\Models\Channel;
use App\Process\ChannelProcessConfiguration;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
/**
* Saves the process of a channel for one intake kind (Kanal › Ablauf, docs/Prozessarchitektur/Architektur/03): the
* chosen model and variant, the step switches and the step settings – in channels.process_overrides[intake], next to
* the existing settings, so their inheritance stays as it is. Refuses everything the configuration does not admit
* (mandatory steps off, responsibilities the model does not allow, tester-only variants). Changes apply to new cases
* only (decision E3): running cases keep their frozen plan.
*/
class ConfigureChannelProcess
{
public function __construct(private ChannelProcessConfiguration $configuration) {}
/**
* @param array{model: string, variant?: string, steps?: array<string, array{on?: bool}>, settings?: array<string, mixed>} $draft
*
* @throws ValidationException
*/
public function handle(Channel $channel, IntakeKind $intake, array $draft, ?string $by = null): Channel
{
$problems = $this->configuration->problems($channel, $intake, $draft);
if ($problems !== []) {
throw ValidationException::withMessages(['process' => $problems]);
}
return DB::transaction(function () use ($channel, $intake, $draft, $by): Channel {
$channel = Channel::query()->lockForUpdate()->findOrFail($channel->id);
$overrides = (array) ($channel->process_overrides ?? []);
$current = (array) ($overrides[$intake->value] ?? []);
$settings = [];
foreach (ProcessSetting::cases() as $setting) {
$value = array_key_exists($setting->value, (array) ($draft['settings'] ?? [])) ? $setting->normalize($draft['settings'][$setting->value]) : $setting->normalize($current[$setting->value] ?? null);
if ($value !== null && in_array($intake, $setting->channelIntakes(), true)) {
$settings[$setting->value] = $value;
}
}
$steps = [];
foreach ((array) ($draft['steps'] ?? []) as $module => $step) {
if (array_key_exists('on', $step) && $step['on'] === false) {
$steps[$module] = ['on' => false];
}
}
$overrides[$intake->value] = [
...$settings,
'model' => $draft['model'],
'variant' => $draft['variant'] ?? 'standard',
'steps' => $steps,
'configured_at' => now()->toIso8601String(),
'configured_by' => $by ?? auth()->user()?->name,
];
$channel->update(['process_overrides' => $overrides]);
return $channel;
});
}
}