Prozesskonfigurator: fachliche Prozessblöcke als Hauptansicht, Detailpanel je Block, Entwurf verwerfen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 15:55:04 +01:00
1 parent 4554af8056
commit 664f00e510
8 files changed
+766 -185

No files matched your search

+125
View File
@@ -0,0 +1,125 @@
<?php
namespace App\Process;
use App\Enums\ProcessSetting;
use App\Process\Modules\ModuleDefinition;
use App\Process\Templates\TemplateArea;
/**
* The business blocks of a resolved course (docs/Prozessarchitektur P01–P05) as the configurator's main view shows them:
* a grouping of modules for the reader, nothing more. What a block depends on is derived from the hard and soft
* dependencies of the modules that are really in the plan and apply (the facts the {@see ProcessRunner} uses, the same
* as {@see ProcessLanes}) – there is no hand-written order between blocks and no arrow between merely adjacent phases.
* Pure: it reads, it never changes anything.
*/
final class ProcessBlocks
{
/**
* Grouping of the modules and the settings a block reports. A module that is in no block would show up under "other",
* so a new module is never lost (a test keeps the catalogue and this table in step).
*
* @var array<string, array{label: string, phase: string, area: ?TemplateArea, modules: list<string>, settings: list<ProcessSetting>}>
*/
public const BLOCKS = [
'intake' => ['label' => 'Eingang und Gastdaten', 'phase' => 'P01', 'area' => null,
'modules' => ['intake.record', 'guest.details', 'guest.data_request', 'guest.address_check', 'guest.loyalty_status', 'pricing.loyalty_discount'],
'settings' => [ProcessSetting::FormRequiresAddress, ProcessSetting::DataRequest, ProcessSetting::DataRequestReminderHours]],
'availability' => ['label' => 'Verfügbarkeit und Reservierung', 'phase' => 'P01', 'area' => null,
'modules' => ['availability.check', 'hold', 'binding.portal', 'channels.block'],
'settings' => [ProcessSetting::PreReservation, ProcessSetting::HoldHours, ProcessSetting::ClarificationHoldAutoMinutes]],
'answer' => ['label' => 'Antwort und Angebot', 'phase' => 'P02', 'area' => TemplateArea::InquiryAnswer,
'modules' => ['offer.information', 'offer.binding', 'offer.acceptance'],
'settings' => [ProcessSetting::InquiryAnswer, ProcessSetting::Processing, ProcessSetting::GuestLinkValidDays]],
'portal_wait' => ['label' => 'Bestätigung des Portals', 'phase' => 'P02', 'area' => null,
'modules' => ['portal.confirmation'],
'settings' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
'documents' => ['label' => 'Dokumentation', 'phase' => 'P03', 'area' => TemplateArea::ContractDocuments,
'modules' => ['documents.send', 'documents.booking_notice', 'documents.stay_confirmation'],
'settings' => [ProcessSetting::Documents, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::ContractTemplate]],
'finance' => ['label' => 'Finanzabwicklung', 'phase' => 'P03', 'area' => TemplateArea::Collection,
'modules' => ['payments.monitor', 'payments.internal', 'portal.payout'],
'settings' => [ProcessSetting::Payments]],
'communication' => ['label' => 'Gastkommunikation und Aufenthalt', 'phase' => 'P04', 'area' => TemplateArea::GuestCommunication,
'modules' => ['arrival.details', 'arrival.info', 'stay', 'review.request'],
'settings' => [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ReviewRequestSender]],
'closure' => ['label' => 'Aufgaben und Abschluss', 'phase' => 'P05', 'area' => null,
'modules' => ['case.tasks', 'change.proposal', 'case.closure', 'case.settlement'],
'settings' => []],
];
public const OTHER = 'other';
public function __construct(private ProcessCatalogue $catalogue) {}
/**
* The blocks of the course the preview rows describe. A block without a step in the plan is left out.
*
* @param list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}> $rows ChannelProcessConfiguration::preview
* @return array<string, array{key: string, label: string, phase: string, area: ?TemplateArea, settings: list<ProcessSetting>, modules: list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}>, active: bool, waits_for: list<array{block: string, label: string, steps: list<string>}>, after: list<array{block: string, label: string}>, independent: bool, events: list<string>, scheduled: list<string>, conditional: list<array{label: string, reason: ?string}>, may_wait: list<string>}>
*/
public function of(array $rows): array
{
$blockOf = [];
foreach (self::BLOCKS as $key => $block) {
foreach ($block['modules'] as $module) {
$blockOf[$module] = $key;
}
}
$other = ['label' => 'Weitere Schritte', 'phase' => 'P03', 'area' => null, 'modules' => [], 'settings' => []];
$blocks = [];
foreach ($rows as $row) {
$key = $blockOf[$row['module']] ?? self::OTHER;
$blocks[$key] ??= [...(self::BLOCKS[$key] ?? $other), 'key' => $key, 'modules' => []];
$blocks[$key]['modules'][] = $row;
}
// Presentation order is the table's, the plan decides which blocks exist.
$blocks = array_merge(array_intersect_key(array_flip([...array_keys(self::BLOCKS), self::OTHER]), $blocks), $blocks);
$active = [];
foreach ($rows as $row) {
if ($row['on']) {
$active[$row['module']] = $row;
}
}
foreach ($blocks as $key => &$block) {
$block['active'] = collect($block['modules'])->contains('on', true);
$block = [...$block, 'waits_for' => [], 'after' => [], 'events' => [], 'scheduled' => [], 'conditional' => [], 'may_wait' => []];
foreach ($block['modules'] as $row) {
$definition = $this->catalogue->modules()[$row['module']]::definition();
if (! $row['on']) {
continue;
}
foreach ($definition->requires as $dependency) {
$targetBlock = $blockOf[$dependency->module] ?? self::OTHER;
if ($dependency->module === 'intake.record' || ! isset($active[$dependency->module]) || $targetBlock === $key) {
continue;
}
$list = $dependency->hard ? 'waits_for' : 'after';
$label = $blocks[$targetBlock]['label'] ?? self::BLOCKS[$targetBlock]['label'] ?? $other['label'];
$entry = $block[$list][$targetBlock] ?? ['block' => $targetBlock, 'label' => $label, 'steps' => []];
$entry['steps'][] = $active[$dependency->module]['label'];
$block[$list][$targetBlock] = $entry;
}
if ($definition->toggle === ModuleDefinition::TOGGLE_EVENT_DRIVEN) {
$block['events'][] = $row['label'];
} elseif ($definition->triggers !== [] && collect($definition->triggers)->every(fn (string $trigger): bool => str_starts_with($trigger, 'schedule:'))) {
$block['scheduled'][] = $row['label'];
}
if ($definition->toggle === ModuleDefinition::TOGGLE_CONDITIONAL) {
$block['conditional'][] = ['label' => $row['label'], 'reason' => $definition->condition];
}
foreach ($definition->waits as $wait) {
$block['may_wait'][] = ['guest' => 'den Gast', 'portal' => 'das Portal', 'landlord' => 'Sie', 'time' => 'eine Frist'][$wait] ?? $wait;
}
}
$block['waits_for'] = array_values($block['waits_for']);
$block['after'] = array_values($block['after']);
$block['may_wait'] = array_values(array_unique($block['may_wait']));
$block['independent'] = $block['active'] && $block['waits_for'] === [];
}
unset($block);
return $blocks;
}
}