Übernimm Übungen aus Shinkan in den Übungsbestand und dokumentiere die Entscheidungen
CI Feature / test (push) Successful in 2m49s
Deploy Test / test (push) Successful in 2m30s
Deploy Test / deploy (push) Successful in 28s

Quellübung mit stabiler Kennung und Inhaltswert, genau ein Stand je Prüfsumme, bewusste Übernahme als neue lokale
Fassung, lokale Ergänzungen bleiben erhalten, Ausblenden an der Quelle setzt nur die Verfügbarkeit. Seite
Übernahme (Shinkan), Feldzuordnung, ADR-49 (inklusive Abweichung bei der Mediensperre), Abnahmestand und
Rückfallverfahren.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-23 17:10:47 +01:00
1 parent bbee288e69
commit 881703ba0e
23 files changed
+1151 -6

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ class CompositionMember extends Model
'variant_id',
'requirement',
'variant_selection',
'origin',
];
public const REQUIRED = 'erforderlich';
@@ -352,6 +352,7 @@ private function materialize(
'variant' => isset($member['variant']) && $member['variant'] !== '' ? (string) $member['variant'] : null,
'requirement' => $member['requirement'] ?? 'erforderlich',
'selection' => is_array($member['selection'] ?? null) && $member['selection'] !== [] ? array_values($member['selection']) : null,
'origin' => $member['origin'] ?? 'lokal',
];
}
@@ -20,6 +20,7 @@ class CompositionVersion extends Model
'duration_max',
'prerequisites',
'structure_hash',
'source_snapshot_id',
];
protected function casts(): array
@@ -12,7 +12,7 @@
*/
class CompositionVersionVariant extends Model
{
protected $fillable = ['composition_version_id', 'key', 'position', 'name', 'description'];
protected $fillable = ['composition_version_id', 'key', 'position', 'name', 'description', 'origin'];
protected static function booted(): void
{
+1
View File
@@ -31,6 +31,7 @@ class ContentElement extends Model
'preview_path',
'editorial_content_kind_id',
'archived_at',
'source_ref',
];
protected function casts(): array
+7 -2
View File
@@ -227,7 +227,7 @@ public function releaseElementVersion(ContentElementVersion $version): ContentEl
/**
* @param list<array{role: string, target: ContentElementVersion|CompositionVersion, note?: string|null, variant?: string|null, requirement?: string|null, selection?: list<string>|null}> $members
* @param array{learning_goal?: mixed, duration_minutes?: mixed, duration_max?: mixed, material_note?: mixed, prerequisites?: mixed} $didactic
* @param list<array{key: string, name: string, description?: string|null}> $variants Durchführungsvarianten einer Übung
* @param list<array{key: string, name: string, description?: string|null, origin?: string}> $variants Durchführungsvarianten einer Übung
*/
public function publishComposition(
Composition $composition,
@@ -261,6 +261,7 @@ public function publishComposition(
'duration_max' => isset($didactic['duration_max']) ? (int) $didactic['duration_max'] : null,
'material_note' => $this->optionalText($didactic['material_note'] ?? null),
'prerequisites' => $this->optionalText($didactic['prerequisites'] ?? null),
'source_snapshot_id' => isset($didactic['source_snapshot_id']) ? (int) $didactic['source_snapshot_id'] : null,
]);
$variantIds = [];
@@ -271,6 +272,7 @@ public function publishComposition(
'position' => $index + 1,
'name' => $variant['name'],
'description' => $variant['description'],
'origin' => $variant['origin'],
])->id;
}
@@ -286,6 +288,7 @@ public function publishComposition(
'variant_id' => isset($member['variant']) ? $variantIds[$member['variant']] : null,
'requirement' => $member['requirement'] ?? CompositionMember::REQUIRED,
'variant_selection' => $selection === null ? null : array_values($selection),
'origin' => ($member['origin'] ?? 'lokal') === 'quelle' ? 'quelle' : 'lokal',
]);
}
@@ -326,7 +329,7 @@ public function structureHash(CompositionVersion $version): string
$version->prerequisites,
],
'variants' => $version->variants->map(fn (CompositionVersionVariant $variant): array => [
$variant->key, $variant->position, $variant->name, $variant->description,
$variant->key, $variant->position, $variant->name, $variant->description, $variant->origin,
])->all(),
'members' => $version->members->map(fn (CompositionMember $member): array => [
$member->position,
@@ -337,6 +340,7 @@ public function structureHash(CompositionVersion $version): string
$member->variant?->key,
$member->requirement,
$member->variant_selection,
$member->origin,
])->all(),
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
}
@@ -362,6 +366,7 @@ private function checkedVariants(array $variants): array
'key' => $key,
'name' => $this->required((string) ($variant['name'] ?? ''), 'Jede Variante braucht einen Namen.'),
'description' => $this->optionalText($variant['description'] ?? null),
'origin' => ($variant['origin'] ?? 'lokal') === 'quelle' ? 'quelle' : 'lokal',
];
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
class ExerciseImportRun extends Model
{
protected $fillable = ['source_system', 'status', 'cursor', 'added', 'updated', 'removed', 'error', 'started_at', 'finished_at'];
protected function casts(): array
{
return ['started_at' => 'datetime', 'finished_at' => 'datetime'];
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Eine Übung der Quelle, gebunden an ihre stabile Kennung. `availability` hält nur fest, ob die Quelle sie noch
* bereitstellt. Das ist kein Rechtsvorgang: Eine rechtliche Sperre ist der lokale `block`.
*/
class ExerciseSource extends Model
{
public const PROVIDED = 'bereitgestellt';
public const WITHDRAWN = 'nicht_mehr_bereitgestellt';
protected $fillable = ['source_system', 'source_id', 'composition_id', 'title', 'availability', 'last_hash', 'last_seen_at'];
protected function casts(): array
{
return ['last_seen_at' => 'datetime'];
}
public function composition(): BelongsTo
{
return $this->belongsTo(Composition::class);
}
public function snapshots(): HasMany
{
return $this->hasMany(ExerciseSourceSnapshot::class)->orderBy('id');
}
public function latestSnapshot(): ?ExerciseSourceSnapshot
{
return $this->snapshots()->reorder()->orderByDesc('id')->first();
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Ein abgerufener Inhaltsstand einer Quellübung (Prüfsumme der Quelle und ihre Nutzlast). Er ist unveränderlich;
* nur die Übernahme trägt die daraus entstandene lokale Fassung ein.
*/
class ExerciseSourceSnapshot extends Model
{
protected $fillable = ['exercise_source_id', 'content_hash', 'payload', 'adopted_version_id', 'fetched_at'];
protected function casts(): array
{
return ['payload' => 'array', 'fetched_at' => 'datetime'];
}
public function source(): BelongsTo
{
return $this->belongsTo(ExerciseSource::class, 'exercise_source_id');
}
public function adoptedVersion(): BelongsTo
{
return $this->belongsTo(CompositionVersion::class, 'adopted_version_id');
}
}
+346
View File
@@ -0,0 +1,346 @@
<?php
namespace App\Domain\Catalog;
use App\Models\User;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Throwable;
/**
* Übernahme von Übungen aus dem Shinkan-Katalog (`GET /api/distribution/v1/catalog` und Detailroute) in denselben
* Übungsbestand wie die lokalen Übungen.
*
* Grundsätze:
* - Die Quellübung ist an ihre stabile Kennung gebunden. Jeder Inhaltsstand (Prüfsumme der Quelle) wird genau einmal
* festgehalten; ein wiederholter Abruf erzeugt nichts Neues.
* - Eine lokale Fassung entsteht nur durch die bewusste Übernahme ({@see adopt}) und ist danach unveränderlich. Lokale
* Ergänzungen (Herkunft „lokal“) bleiben bei einer neuen Quellfassung erhalten.
* - Das Ausblenden an der Quelle setzt nur die Verfügbarkeit. Lokale Fassungen und Verwendungen bleiben unberührt; eine
* rechtliche Sperre ist der lokale `block`.
* - Medien des Katalogs sind Metadaten ohne Datei. Sie begründen weder eine Ausgabe noch eine Nutzungsberechtigung und
* stehen nie in einem Artikel-Stand.
* - Ein fehlgeschlagener Abruf verändert den gespeicherten Stand nicht und rückt den Cursor nicht vor.
*/
class ShinkanImport
{
/** Abschnitte der Quelle in Lesereihenfolge: Feld => [Bezeichnung, Rolle]. */
private const SECTIONS = [
'preparation' => 'Vorbereitung',
'execution' => 'Durchführung',
'trainer_notes' => 'Trainerhinweise',
];
public function configured(): bool
{
return filled(config('services.shinkan.url')) && filled(config('services.shinkan.key'));
}
public function fetch(): ExerciseImportRun
{
$run = ExerciseImportRun::query()->create(['status' => 'laeuft', 'started_at' => now()]);
if (! $this->configured()) {
return $this->finish($run, 'fehler', error: 'Die Anbindung ist nicht eingerichtet. Adresse und Schlüssel fehlen in der Umgebung.');
}
$previous = ExerciseImportRun::query()->where('status', 'ok')->orderByDesc('id')->value('cursor');
$counts = ['added' => 0, 'updated' => 0, 'removed' => 0];
try {
try {
$catalog = $this->get('/catalog', $previous === null ? [] : ['cursor' => $previous]);
} catch (RequestException $exception) {
// Ein ungültiger Cursor heißt nur: ganz neu abgleichen.
if ($previous === null || $exception->response->status() !== 400) {
throw $exception;
}
$catalog = $this->get('/catalog');
}
foreach ((array) ($catalog['changes'] ?? []) as $change) {
$id = (string) ($change['source_id'] ?? '');
$kind = (string) ($change['change'] ?? '');
if ($id === '') {
continue;
}
if ($kind === 'removed') {
ExerciseSource::query()->where('source_system', 'shinkan')->where('source_id', $id)
->update(['availability' => ExerciseSource::WITHDRAWN]);
$counts['removed']++;
continue;
}
$document = $this->get('/catalog/'.$id);
$this->record($document);
$counts[$kind === 'added' ? 'added' : 'updated']++;
}
foreach ((array) ($catalog['exercises'] ?? []) as $listed) {
ExerciseSource::query()->where('source_system', 'shinkan')->where('source_id', (string) ($listed['source_id'] ?? ''))
->update(['availability' => ExerciseSource::PROVIDED, 'last_seen_at' => now()]);
}
} catch (Throwable $exception) {
return $this->finish($run, 'fehler', $counts, 'Der Abruf ist fehlgeschlagen: '.$this->plain($exception).' Der gespeicherte Stand blieb unverändert.');
}
return $this->finish($run, 'ok', $counts, null, (string) ($catalog['next_cursor'] ?? $previous));
}
/**
* Hält einen abgerufenen Inhaltsstand fest. Derselbe Stand (Quelle und Prüfsumme) wird nie doppelt gespeichert.
*
* @param array<string, mixed> $document Detail der Quelle mit `source_id`, `content_hash` und den Feldern
*/
public function record(array $document): ExerciseSourceSnapshot
{
$id = (string) ($document['source_id'] ?? '');
$hash = (string) ($document['content_hash'] ?? '');
if ($id === '' || $hash === '') {
throw new DomainRuleException('Der Abruf liefert keine Quellkennung oder Prüfsumme.');
}
return DB::transaction(function () use ($id, $hash, $document): ExerciseSourceSnapshot {
$source = ExerciseSource::query()->firstOrCreate(
['source_system' => 'shinkan', 'source_id' => $id],
['title' => (string) ($document['title'] ?? '')],
);
$source->update([
'title' => (string) ($document['title'] ?? $source->title),
'availability' => ExerciseSource::PROVIDED,
'last_hash' => $hash,
'last_seen_at' => now(),
]);
return $source->snapshots()->firstOrCreate(
['content_hash' => $hash],
['payload' => $document, 'fetched_at' => now()],
);
});
}
/**
* Zustand einer Quellübung für die Redaktion.
*/
public function state(ExerciseSource $source): string
{
$latest = $source->latestSnapshot();
return match (true) {
$source->availability === ExerciseSource::WITHDRAWN => 'nicht_mehr_bereitgestellt',
$latest === null => 'neu',
$latest->adopted_version_id !== null => 'uebernommen',
$source->composition_id !== null => 'geaendert',
default => 'neu',
};
}
/**
* Die bewusste Übernahme: aus dem Inhaltsstand wird eine neue, unveränderliche lokale Fassung. Wiederholt man sie,
* entsteht keine zweite Fassung. Lokale Ergänzungen der bisherigen Fassung werden übernommen.
*/
public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null): CompositionVersion
{
$snapshot->refresh();
if ($snapshot->adopted_version_id !== null) {
return $snapshot->adoptedVersion;
}
return DB::transaction(function () use ($snapshot, $actor): CompositionVersion {
$source = $snapshot->source;
$document = $snapshot->payload;
$content = app(ContentService::class);
$title = trim((string) ($document['title'] ?? '')) ?: 'Übung aus Shinkan';
$composition = $source->composition ?? $this->createComposition($title, (string) ($document['summary'] ?? ''));
$previous = $composition->versions()->orderByDesc('number')->with('members.variant', 'variants')->first();
$variants = [];
$members = [];
foreach (self::SECTIONS as $field => $label) {
$text = trim((string) ($document[$field] ?? ''));
if ($text !== '') {
$members[] = [
'role' => $label,
'target' => $this->section($source, $field, $title.' · '.$label, $text),
'origin' => 'quelle',
];
}
}
foreach ((array) ($document['variants'] ?? []) as $variant) {
$key = (string) ($variant['id'] ?? '');
if ($key === '') {
continue;
}
$variants[] = [
'key' => $key,
'name' => (string) ($variant['name'] ?? '') ?: 'Variante',
'description' => (string) ($variant['description'] ?? ''),
'origin' => 'quelle',
];
$changes = trim((string) ($variant['execution_changes'] ?? ''));
if ($changes !== '') {
$members[] = [
'role' => 'Abweichung der Durchführung',
'target' => $this->section($source, 'variant:'.$key, $title.' · '.($variant['name'] ?? 'Variante').' · Abweichung', $changes),
'variant' => $key,
'origin' => 'quelle',
];
}
}
[$localMembers, $localVariants] = $this->localAdditions($previous, array_column($variants, 'key'));
$version = $content->publishComposition(
$composition,
[...$members, ...$localMembers],
$actor,
'Übernahme aus Shinkan',
[
'learning_goal' => $document['goal'] ?? null,
'duration_minutes' => $document['duration_min'] ?? null,
'duration_max' => $document['duration_max'] ?? null,
'material_note' => $document['equipment'] ?? null,
'source_snapshot_id' => $snapshot->id,
],
[...$variants, ...$localVariants],
);
$snapshot->update(['adopted_version_id' => $version->id]);
$source->update(['composition_id' => $composition->id]);
return $version;
});
}
/**
* Was die Redaktion lokal ergänzt hat, bleibt bei einer neuen Quellfassung erhalten. Eine lokale Zuordnung zu einer
* Quellvariante, die es nicht mehr gibt, wandert in den gemeinsamen Teil, damit nichts verloren geht.
*
* @param list<string> $sourceVariantKeys
* @return array{0: list<array<string, mixed>>, 1: list<array<string, mixed>>}
*/
private function localAdditions(?CompositionVersion $previous, array $sourceVariantKeys): array
{
if ($previous === null) {
return [[], []];
}
$localVariants = $previous->variants->where('origin', 'lokal')->map(fn (CompositionVersionVariant $variant): array => [
'key' => $variant->key, 'name' => $variant->name, 'description' => $variant->description, 'origin' => 'lokal',
])->values()->all();
$known = [...$sourceVariantKeys, ...array_column($localVariants, 'key')];
$members = [];
foreach ($previous->members->where('origin', 'lokal') as $member) {
$variant = $member->variant?->key;
$members[] = [
'role' => $member->role,
'note' => $member->placement_note,
'target' => $member->content_element_version_id !== null ? $member->contentElementVersion : $member->nestedCompositionVersion,
'variant' => $variant !== null && in_array($variant, $known, true) ? $variant : null,
'requirement' => $member->requirement,
'selection' => $member->variant_selection,
'origin' => 'lokal',
];
}
return [$members, $localVariants];
}
/**
* Die Textfassung eines Abschnitts der Quelle. Unveränderter Text bleibt dieselbe Fassung.
*/
private function section(ExerciseSource $source, string $field, string $title, string $text): ContentElementVersion
{
$content = app(ContentService::class);
$ref = 'shinkan:'.$source->source_id.':'.$field;
$element = ContentElement::query()->where('source_ref', $ref)->first();
if ($element === null) {
$element = $content->createElement('text', 'text', $title);
$element->source_ref = $ref;
$element->save();
}
$latest = $element->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first();
return $latest !== null && trim((string) $latest->body) === $text
? $latest
: $content->publishElementVersion($element, $text, [], 'Übernahme aus Shinkan');
}
private function createComposition(string $title, string $summary): Composition
{
$composition = app(ContentService::class)->createComposition($title, CompositionKind::Exercise);
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'uebung')->value('id');
if ($summary !== '') {
$composition->summary = $summary;
}
$composition->save();
return $composition;
}
/**
* @param array<string, mixed> $query
* @return array<string, mixed>
*/
private function get(string $path, array $query = []): array
{
$response = Http::withToken((string) config('services.shinkan.key'))
->acceptJson()
->timeout(20)
->get(rtrim((string) config('services.shinkan.url'), '/').'/api/distribution/v1'.$path, $query)
->throw();
$json = $response->json();
if (! is_array($json)) {
throw new DomainRuleException('Die Antwort der Quelle ist kein gültiges JSON.');
}
return $json;
}
/**
* @param array{added?: int, updated?: int, removed?: int} $counts
*/
private function finish(ExerciseImportRun $run, string $status, array $counts = [], ?string $error = null, ?string $cursor = null): ExerciseImportRun
{
$run->update([
'status' => $status,
'cursor' => $cursor,
'added' => $counts['added'] ?? 0,
'updated' => $counts['updated'] ?? 0,
'removed' => $counts['removed'] ?? 0,
'error' => $error,
'finished_at' => now(),
]);
return $run;
}
/** Fehlertext ohne Adresse und Schlüssel. */
private function plain(Throwable $exception): string
{
if ($exception instanceof RequestException) {
return 'Die Quelle antwortete mit Status '.$exception->response->status().'.';
}
return $exception instanceof DomainRuleException ? $exception->getMessage() : 'Die Quelle ist nicht erreichbar.';
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
namespace App\Filament\Pages;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\ExerciseImportRun;
use App\Domain\Catalog\ExerciseSource;
use App\Domain\Catalog\ExerciseSourceSnapshot;
use App\Domain\Catalog\ShinkanImport;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Resources\Practices\PracticeResource;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Pages\Page;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable;
/**
* Übernahme aus Shinkan: Welche Übungen stellt die Quelle bereit, was ist neu oder geändert, was ist übernommen und was
* stellt die Quelle nicht mehr bereit? Abrufen verändert nur den Quellenstand; erst „Übernehmen“ legt eine lokale
* Fassung an, und erst eine Produktveröffentlichung setzt sie ein.
*/
class Uebernahme extends Page
{
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
protected static ?string $navigationLabel = 'Übernahme (Shinkan)';
protected static ?int $navigationSort = 6;
protected static ?string $slug = 'uebernahme';
protected static ?string $title = 'Übernahme aus Shinkan';
protected string $view = 'filament.pages.uebernahme';
public string $feedback = '';
public bool $feedbackError = false;
public static function canAccess(): bool
{
return ContentElementResource::editor();
}
public function getHeading(): string|Htmlable|null
{
return null;
}
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
public function fetch(): void
{
abort_unless(static::canAccess(), 403);
$run = app(ShinkanImport::class)->fetch();
$this->feedbackError = $run->status !== 'ok';
$this->feedback = $run->status === 'ok'
? 'Abruf abgeschlossen: '.$run->added.' neu, '.$run->updated.' geändert, '.$run->removed.' nicht mehr bereitgestellt. Es wurde noch keine lokale Fassung angelegt.'
: (string) $run->error;
}
public function adopt(int $snapshotId): void
{
abort_unless(static::canAccess(), 403);
try {
$user = Filament::auth()->user();
$version = app(ShinkanImport::class)->adopt(ExerciseSourceSnapshot::query()->findOrFail($snapshotId), $user instanceof User ? $user : null);
$this->feedbackError = false;
$this->feedback = 'Fassung '.$version->number.' ist lokal angelegt und unveränderlich. Produkte verwenden sie erst, wenn du sie dort bewusst einsetzt und das Produkt veröffentlichst.';
} catch (DomainRuleException $exception) {
$this->feedbackError = true;
$this->feedback = $exception->getMessage();
}
}
/**
* @return array<string, mixed>
*/
public function daten(): array
{
$import = app(ShinkanImport::class);
$labels = [
'neu' => ['Neu bei der Quelle', 'offen'],
'geaendert' => ['Neue Quellfassung zur Übernahme', 'offen'],
'uebernommen' => ['Übernommen', 'gut'],
'nicht_mehr_bereitgestellt' => ['An der Quelle nicht mehr bereitgestellt', 'leise'],
];
$rows = [];
foreach (ExerciseSource::query()->with('composition')->orderBy('title')->get() as $source) {
$state = $import->state($source);
$latest = $source->latestSnapshot();
$payload = $latest?->payload ?? [];
$rows[] = [
'titel' => $source->title ?: $source->source_id,
'zustand' => $labels[$state][0],
'ton' => $labels[$state][1],
'snapshot' => $latest !== null && $latest->adopted_version_id === null ? $latest->id : null,
'lokal' => $source->composition === null ? null : PracticeResource::getUrl('edit', ['record' => $source->composition]),
'varianten' => count($payload['variants'] ?? []),
'quellmedien' => array_map(fn (array $media): string => ($media['title'] ?? '').' ('.($media['media_type'] ?? '').')', (array) ($payload['media'] ?? [])),
'hinweis' => $state === 'nicht_mehr_bereitgestellt'
? 'Lokale Fassungen und Verwendungen bleiben unverändert. Eine rechtliche Sperre ist ein eigener Vorgang am Medium.'
: null,
];
}
return [
'zeilen' => $rows,
'eingerichtet' => app(ShinkanImport::class)->configured(),
'letzterLauf' => ExerciseImportRun::query()->orderByDesc('id')->first(),
];
}
}
@@ -523,7 +523,7 @@ public function addVariant(): void
$key = $base.'-'.$n++;
}
$this->variants[] = ['key' => $key, 'name' => $name, 'description' => ''];
$this->variants[] = ['key' => $key, 'name' => $name, 'description' => '', 'origin' => 'lokal'];
$this->newVariantName = '';
$this->feedback = 'Variante „'.$name.'“ ist angelegt. Ordne ihr Bestandteile zu. Gespeichert wird mit „Entwurf speichern“.';
}
@@ -599,7 +599,7 @@ public function offeredVariants(string $target): array
/**
* @param array<string, mixed> $member
* @return array{variant: string|null, requirement: string, selection: list<string>|null}
* @return array{variant: string|null, requirement: string, selection: list<string>|null, origin: string}
*/
private function memberExtras(array $member): array
{
@@ -609,6 +609,7 @@ private function memberExtras(array $member): array
'variant' => isset($member['variant']) && $member['variant'] !== '' ? (string) $member['variant'] : null,
'requirement' => ($member['requirement'] ?? 'erforderlich') === 'ergaenzend' ? 'ergaenzend' : 'erforderlich',
'selection' => is_array($selection) && $selection !== [] ? array_values(array_map('strval', $selection)) : null,
'origin' => ($member['origin'] ?? 'lokal') === 'quelle' ? 'quelle' : 'lokal',
];
}
@@ -625,6 +626,7 @@ private function normalizeVariants(mixed $variants): array
'key' => trim((string) $variant['key']),
'name' => trim((string) ($variant['name'] ?? '')),
'description' => trim((string) ($variant['description'] ?? '')),
'origin' => ($variant['origin'] ?? 'lokal') === 'quelle' ? 'quelle' : 'lokal',
];
}
}
@@ -2353,7 +2355,7 @@ protected function readyPayload(): array
'duration_max' => $version->duration_max === null ? null : (string) $version->duration_max,
'prerequisites' => $version->prerequisites,
'variants' => $this->normalizeVariants($version->variants->map(fn ($variant): array => [
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description,
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'origin' => $variant->origin,
])->all()),
'revision_note' => null,
'members' => array_values(array_map(
@@ -55,6 +55,7 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr
$row['variant'] = $member->variant?->key;
$row['requirement'] = $member->requirement ?: 'erforderlich';
$row['selection'] = is_array($member->variant_selection) ? $member->variant_selection : null;
$row['origin'] = $member->origin ?: 'lokal';
$rows[] = $row;
}