Konfigurator: Ablauf im Zusammenhang aus dem Plan, Nachrichtenregeln, einheitliche Anfrage-/Buchungsansicht; Abnahmetests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 12:45:46 +01:00
1 parent 221ce8ca81
commit b1b09a6db4
7 files changed
+616 -36

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
<?php
namespace App\Process;
use App\Process\Modules\ModuleDefinition;
/**
* The course of a resolved plan as the runner executes it: which steps start at once and run in parallel, which wait
* for others, which are conditional, event-driven or time-driven. Derived only from the same facts the
* {@see ProcessRunner} uses – the hard dependencies among the steps that are in the plan and apply, `applies()` (as the
* preview row's reason), the trigger kinds and what a step waits for. No grouping by phase, no hand-written text.
* Pure: it reads, it never changes anything.
*/
final class ProcessLanes
{
public function __construct(private ProcessCatalogue $catalogue) {}
/**
* @param list<array{module: string, label: string, on: bool, reason: ?string}> $rows the preview rows of a draft (ChannelProcessConfiguration::preview)
* @return array{parallel: list<array{module: string, label: string, note: ?string}>, waiting: list<array{module: string, label: string, note: ?string, after: list<string>}>, event: list<array{module: string, label: string, note: ?string}>, later: list<array{module: string, label: string, note: ?string}>, off: list<array{module: string, label: string, note: ?string}>}
*/
public function of(array $rows): array
{
$active = [];
foreach ($rows as $row) {
if ($row['on']) {
$active[$row['module']] = $row['label'];
}
}
$lanes = ['parallel' => [], 'waiting' => [], 'event' => [], 'later' => [], 'off' => []];
foreach ($rows as $row) {
$definition = $this->catalogue->modules()[$row['module']]::definition();
if (! $row['on']) {
$lanes['off'][] = ['module' => $row['module'], 'label' => $row['label'], 'note' => $row['reason']];
continue;
}
if ($row['module'] === 'intake.record') {
continue;
}
$hard = array_values(array_map(fn ($dependency): string => $active[$dependency->module], array_filter($definition->requires, fn ($dependency): bool => $dependency->hard && $dependency->module !== 'intake.record' && isset($active[$dependency->module]))));
$item = ['module' => $row['module'], 'label' => $row['label'], 'note' => $this->note($definition)];
$lanes[match (true) {
$hard !== [] => 'waiting',
$definition->toggle === ModuleDefinition::TOGGLE_EVENT_DRIVEN => 'event',
$definition->triggers !== [] && collect($definition->triggers)->every(fn (string $trigger): bool => str_starts_with($trigger, 'schedule:')) => 'later',
default => 'parallel',
}][] = $hard !== [] ? [...$item, 'after' => $hard] : $item;
}
return $lanes;
}
private function note(ModuleDefinition $definition): ?string
{
$waits = array_map(fn (string $wait): string => ['guest' => 'den Gast', 'portal' => 'das Portal', 'landlord' => 'Sie', 'time' => 'eine Frist'][$wait] ?? $wait, $definition->waits);
return $waits === [] ? null : 'kann warten auf '.implode(', ', $waits);
}
}