Antwortart (Auskunft/Angebot) und Reservierung sind entkoppelt (neue Einstellung inquiry_answer; pre_reservation bleibt die Reservierungsstrategie). Anlass-bezogene Absender für Anreise-Information und Bewertungsbitte; Schablonen liefern Standardwerte unterhalb aller einstellbaren Ebenen. A1/A2 bleiben Voreinstellungen und Altfassungen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
192 lines
5.7 KiB
PHP
192 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace App\Process\Models;
|
|
|
|
use App\Enums\CaseType;
|
|
use App\Enums\IntakeKind;
|
|
use App\Enums\ProcessSetting;
|
|
use App\Process\ProcessCatalogue;
|
|
use App\Process\Templates\TemplateArea;
|
|
|
|
/**
|
|
* A centrally defined, versioned process model (docs/Prozessarchitektur/Architektur/02 §5): its course of steps with
|
|
* extension points, its admissible variants and the responsibilities it fixes. The case type stays the derived
|
|
* classification (ProcessProfile::caseTypeFor); a model only declares which case types it is admissible for.
|
|
* The landlord chooses among models, he never defines one.
|
|
*/
|
|
abstract class ProcessModel
|
|
{
|
|
abstract public static function key(): string;
|
|
|
|
abstract public static function version(): int;
|
|
|
|
abstract public static function label(): string;
|
|
|
|
abstract public static function description(): string;
|
|
|
|
/** @return list<CaseType> */
|
|
abstract public static function caseTypes(): array;
|
|
|
|
/** @return list<IntakeKind> */
|
|
abstract public static function intakes(): array;
|
|
|
|
abstract public static function responsibilities(): Responsibilities;
|
|
|
|
/** @return list<Step> */
|
|
abstract public function steps(): array;
|
|
|
|
/**
|
|
* What a channel must be able to do (and not do) for this model to fit: capability key => required value. Empty:
|
|
* the model fits every channel that delivers its intake kind (docs/Prozessarchitektur/V2.1/02 §3.2).
|
|
*
|
|
* @return array<string, bool>
|
|
*/
|
|
public static function capabilityRequirements(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Settings the model fixes for its cases (e.g. the pre-reservation of the offer model).
|
|
*
|
|
* @return array<string, string|int|bool>
|
|
*/
|
|
public static function fixes(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* @return list<Variant>
|
|
*/
|
|
public function variants(): array
|
|
{
|
|
return [Variant::make('standard', 'Standard')];
|
|
}
|
|
|
|
public function variant(string $key): ?Variant
|
|
{
|
|
foreach ($this->variants() as $variant) {
|
|
if ($variant->key === $key) {
|
|
return $variant;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* The function template areas this model offers a slot for (empty: the model's course is fixed).
|
|
*
|
|
* @return list<TemplateArea>
|
|
*/
|
|
public function slots(): array
|
|
{
|
|
return array_values(array_map(fn (Step $step): TemplateArea => $step->slot, array_filter($this->steps(), fn (Step $step): bool => $step->isSlot())));
|
|
}
|
|
|
|
/**
|
|
* Templates a model does not take, with the business reason (template key => reason). Everything not listed fits.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public static function templateRestrictions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* For a legacy model: the key of the base process whose template combination it reproduces.
|
|
*/
|
|
public static function composedBy(): ?string
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* The results the base course provides to the templates of its slots (see FunctionTemplate::requires()).
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
public static function providedResults(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* The template (key) every slot gets when none was chosen: area value => template key.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public static function defaultTemplates(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Whether the model is kept for compatibility (existing channels and frozen plans) and no longer offered as a
|
|
* choice: its combination is a preset of a composable model.
|
|
*/
|
|
public static function isLegacy(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* The template combination that reproduces this legacy model (area value => template key), or empty.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public static function presetTemplates(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* The modules of the course in order, with the variant's modules at their points and the chosen templates' modules
|
|
* at their slots.
|
|
*
|
|
* @param array<string, string> $templates area value => template key or key@version (missing areas: the default)
|
|
* @return list<string>
|
|
*/
|
|
public function modules(?string $variant = 'standard', array $templates = []): array
|
|
{
|
|
$chosen = $this->variant($variant ?? 'standard');
|
|
$catalogue = app(ProcessCatalogue::class);
|
|
$modules = [];
|
|
foreach ($this->steps() as $step) {
|
|
if ($step->isPoint()) {
|
|
array_push($modules, ...($chosen?->modulesAt($step->point) ?? []));
|
|
} elseif ($step->isSlot()) {
|
|
$reference = $templates[$step->slot->value] ?? static::defaultTemplates()[$step->slot->value] ?? null;
|
|
if ($reference !== null && ($class = $catalogue->templateClass($reference)) !== null) {
|
|
array_push($modules, ...$class::modules());
|
|
}
|
|
} else {
|
|
$modules[] = $step->module;
|
|
}
|
|
}
|
|
|
|
return $modules;
|
|
}
|
|
|
|
/**
|
|
* @return list<Point>
|
|
*/
|
|
public function points(): array
|
|
{
|
|
return array_values(array_map(fn (Step $step): Point => $step->point, array_filter($this->steps(), fn (Step $step): bool => $step->isPoint())));
|
|
}
|
|
|
|
public static function reference(): string
|
|
{
|
|
return static::key().'@'.static::version();
|
|
}
|
|
|
|
/** Whether the model fixes the setting (the configurator shows it, but not as a choice). */
|
|
public static function fixesSetting(ProcessSetting $setting): bool
|
|
{
|
|
return array_key_exists($setting->value, static::fixes());
|
|
}
|
|
}
|