Schablonenkomposition: Basisprozess external.booking mit Platz für Finanz- und Dokumentenschablonen
Vier Schablonen (Eigenes/Portal-Inkasso, Eigene/Externe Vertragsdokumentation) in app/Process/Templates, TemplateComposer prüft Ergebnisse, Verantwortlichkeiten, Ausschlüsse und harte Modulabhängigkeiten. Der Plan friert die Schablonenversionen ein. A3–A5 bleiben als Voreinstellungen; die vierte Kombination (eigenes Inkasso + externe Unterlagen) ist darstellbar. Konfigurator-Logik und ConfigureChannelProcess kennen die Schablonenwahl. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
381720763c
commit
e95ba4f986
24 files changed
+1666
-37
No files matched your search
@@ -7,6 +7,8 @@
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\Modules\ProcessModule;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\Templates\FunctionTemplate;
|
||||
use App\Process\Templates\TemplateArea;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@@ -97,6 +99,53 @@ public function models(): array
|
||||
return $models;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, class-string<FunctionTemplate>>>
|
||||
*/
|
||||
public function templateVersions(): array
|
||||
{
|
||||
return (array) config('process.templates', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class of a template named by key (latest version) or key@version; null when it is not registered.
|
||||
*
|
||||
* @return class-string<FunctionTemplate>|null
|
||||
*/
|
||||
public function templateClass(string $reference): ?string
|
||||
{
|
||||
[$key, $version] = array_pad(explode('@', $reference, 2), 2, null);
|
||||
$versions = $this->templateVersions()[$key] ?? [];
|
||||
if ($versions === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $versions[$version === null ? max(array_keys($versions)) : (int) $version] ?? null;
|
||||
}
|
||||
|
||||
public function hasTemplate(string $reference): bool
|
||||
{
|
||||
return $this->templateClass($reference) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The latest version of every template, optionally of one area.
|
||||
*
|
||||
* @return array<string, class-string<FunctionTemplate>>
|
||||
*/
|
||||
public function templates(?TemplateArea $area = null): array
|
||||
{
|
||||
$templates = [];
|
||||
foreach (array_keys($this->templateVersions()) as $key) {
|
||||
$class = $this->templateClass($key);
|
||||
if ($area === null || $class::area() === $area) {
|
||||
$templates[$key] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* The model a case follows when nobody chose one: derived from its frozen profile exactly as the v0.11 course
|
||||
* branched (legacy mapping, docs/Prozessarchitektur/Architektur/06 §4).
|
||||
@@ -151,12 +200,42 @@ public function problems(): array
|
||||
$problems[] = 'Zyklische harte Abhängigkeit: '.implode(' → ', $cycle);
|
||||
}
|
||||
|
||||
foreach ($this->templateVersions() as $key => $versions) {
|
||||
foreach ($versions as $version => $class) {
|
||||
if ($class::key() !== $key || $class::version() !== $version) {
|
||||
$problems[] = "Schablone {$key}@{$version}: Klasse {$class} meldet ".$class::reference().'.';
|
||||
}
|
||||
foreach ($class::modules() as $module) {
|
||||
if (! $this->hasModule($module)) {
|
||||
$problems[] = "Schablone {$class::reference()}: Modul {$module} ist nicht registriert.";
|
||||
}
|
||||
}
|
||||
if (! in_array($class::area()->result(), $class::provides(), true)) {
|
||||
$problems[] = "Schablone {$class::reference()}: liefert das Ergebnis ihres Bereichs ({$class::area()->result()}) nicht.";
|
||||
}
|
||||
if ($class::fixes() === [] || array_keys($class::fixes()) !== [$class::area()->setting()->value]) {
|
||||
$problems[] = "Schablone {$class::reference()}: darf nur die Verantwortlichkeit ihres Bereichs festlegen.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->modelVersions() as $key => $versions) {
|
||||
foreach ($versions as $version => $class) {
|
||||
if ($class::key() !== $key || $class::version() !== $version) {
|
||||
$problems[] = "Modell {$key}@{$version}: Klasse {$class} meldet ".$class::key().'@'.$class::version().'.';
|
||||
}
|
||||
$model = app($class);
|
||||
foreach ($model->slots() as $area) {
|
||||
$default = $class::defaultTemplates()[$area->value] ?? null;
|
||||
if ($default === null || ! $this->hasTemplate($default) || $this->templateClass($default)::area() !== $area) {
|
||||
$problems[] = "Modell {$key}@{$version}: Platz {$area->value} hat keine gültige Standardschablone.";
|
||||
}
|
||||
}
|
||||
foreach ($class::presetTemplates() as $area => $reference) {
|
||||
if (! $this->hasTemplate($reference) || $this->templateClass($reference)::area()->value !== $area) {
|
||||
$problems[] = "Modell {$key}@{$version}: Voreinstellung {$area} nennt die Schablone {$reference} nicht (richtig).";
|
||||
}
|
||||
}
|
||||
foreach ($model->variants() as $variant) {
|
||||
foreach ($model->modules($variant->key) as $module) {
|
||||
if (! $this->hasModule($module)) {
|
||||
|
||||
Reference in new issue
Block a user