Halte Auswirkung und Rückzug beim Veröffentlichen eines Artikel-Stands fest.
Deploy Test / test (push) Successful in 12s
Deploy Test / deploy (push) Successful in 32s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 09:07:14 +01:00
1 parent fd6860efda
commit fef0ea2ac2
11 files changed
+298 -25

No files matched your search

+26 -8
View File
@@ -18,6 +18,7 @@ class ArticleRelease extends Model
'block_reason',
'fallback_release_id',
'change_note',
'impact_report',
'root_element_version_id',
'root_composition_version_id',
];
@@ -27,6 +28,7 @@ protected function casts(): array
return [
'important' => 'boolean',
'status' => ReleaseStatus::class,
'impact_report' => 'array',
];
}
@@ -34,24 +36,40 @@ protected static function booted(): void
{
static::updating(function (ArticleRelease $release): void {
$original = StatusValue::of($release->getOriginal('status'));
if (! in_array($original, [
$next = StatusValue::of($release->status);
$locked = [
ReleaseStatus::Veroeffentlicht->value,
ReleaseStatus::AbgeloestVerfuegbar->value,
], true)) {
ReleaseStatus::Gesperrt->value,
];
if (! in_array($original, $locked, true)) {
return;
}
$dirty = array_diff(array_keys($release->getDirty()), ['status', 'updated_at']);
$allowedFields = ['status', 'updated_at'];
if ($dirty !== []) {
if ($original === ReleaseStatus::Veroeffentlicht->value && $next === ReleaseStatus::Gesperrt->value) {
$allowedFields = ['status', 'updated_at', 'block_reason', 'fallback_release_id'];
}
if (array_diff(array_keys($release->getDirty()), $allowedFields) !== []) {
throw new DomainRuleException('Ein veröffentlichter Artikel-Stand ist unveränderlich.');
}
$next = StatusValue::of($release->status);
$allowed = match ($original) {
ReleaseStatus::Veroeffentlicht->value => [
ReleaseStatus::AbgeloestVerfuegbar->value,
ReleaseStatus::Gesperrt->value,
],
ReleaseStatus::AbgeloestVerfuegbar->value => [
ReleaseStatus::Veroeffentlicht->value,
],
default => [],
};
if ($original === ReleaseStatus::Veroeffentlicht->value && $next !== ReleaseStatus::AbgeloestVerfuegbar->value) {
throw new DomainRuleException('Ein veröffentlichter Artikel-Stand kann nur abgelöst werden.');
if (! in_array($next, $allowed, true)) {
throw new DomainRuleException('Dieser Statuswechsel eines Artikel-Stands ist nicht zulässig.');
}
});
}