Zeige Medienfassungen in der Verwaltung und halte Beschreibungen davon getrennt.
Deploy Test / test (push) Successful in 15s
Deploy Test / deploy (push) Successful in 22s

Eine Fassung bleibt nummeriert und kann deaktiviert werden. Beschreibung und fachliche Säulen gehören zum Medium und legen keine neue Fassung an.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 11:25:08 +01:00
1 parent 12f12117dd
commit af85a94cd5
28 files changed
+1002 -168

No files matched your search

+7
View File
@@ -3,6 +3,7 @@
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ContentElement extends Model
@@ -11,6 +12,7 @@ class ContentElement extends Model
'kind',
'output_class',
'working_title',
'description',
'archived_at',
];
@@ -25,4 +27,9 @@ public function versions(): HasMany
{
return $this->hasMany(ContentElementVersion::class);
}
public function pillars(): BelongsToMany
{
return $this->belongsToMany(Pillar::class)->orderBy('pillars.name');
}
}
+11 -1
View File
@@ -15,6 +15,7 @@ class ContentElementVersion extends Model
'body',
'metadata',
'change_note',
'block_reason',
];
protected function casts(): array
@@ -37,7 +38,16 @@ protected static function booted(): void
return;
}
$dirty = array_diff(array_keys($version->getDirty()), ['status', 'updated_at']);
$allowed = ['status', 'updated_at'];
if (
$original === ContentVersionStatus::Bereit->value
&& StatusValue::of($version->status) === ContentVersionStatus::Gesperrt->value
) {
$allowed[] = 'block_reason';
}
$dirty = array_diff(array_keys($version->getDirty()), $allowed);
if ($dirty !== [] || $original === ContentVersionStatus::Gesperrt->value) {
throw new DomainRuleException('Eine bereitgestellte Inhaltsfassung ist unveränderlich.');
+13
View File
@@ -30,9 +30,22 @@ public function block(ContentElementVersion|CompositionVersion $version, string
}
$version->status = ContentVersionStatus::Gesperrt;
if ($version instanceof ContentElementVersion) {
$version->block_reason = trim($reason);
}
$version->save();
}
public function describe(ContentElement $element, string $workingTitle, ?string $description): void
{
$element->working_title = $this->required($workingTitle, 'Der Arbeitstitel fehlt.');
$description = trim((string) $description);
$element->description = $description === '' ? null : $description;
$element->save();
}
public function publishElementVersion(
ContentElement $element,
?string $body = null,
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Pillar extends Model
{
protected $fillable = [
'name',
];
public function elements(): BelongsToMany
{
return $this->belongsToMany(ContentElement::class);
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace App\Domain\Catalog;
class PillarService
{
public function create(string $name): Pillar
{
$name = $this->name($name);
if (Pillar::query()->where('name', $name)->exists()) {
throw new DomainRuleException('Diese fachliche Säule gibt es schon.');
}
return Pillar::query()->create(['name' => $name]);
}
public function rename(Pillar $pillar, string $name): void
{
$name = $this->name($name);
if (Pillar::query()->where('name', $name)->whereKeyNot($pillar->id)->exists()) {
throw new DomainRuleException('Diese fachliche Säule gibt es schon.');
}
$pillar->name = $name;
$pillar->save();
}
public function delete(Pillar $pillar): void
{
if ($pillar->elements()->exists()) {
throw new DomainRuleException('Eine Säule mit zugeordneten Medien wird nicht gelöscht.');
}
$pillar->delete();
}
/**
* @param list<int> $pillarIds
*/
public function assign(ContentElement $element, array $pillarIds): void
{
$ids = array_values(array_unique(array_map(intval(...), $pillarIds)));
if (Pillar::query()->whereIn('id', $ids)->count() !== count($ids)) {
throw new DomainRuleException('Eine fachliche Säule fehlt.');
}
$element->pillars()->sync($ids);
}
private function name(string $name): string
{
$name = trim($name);
if ($name === '') {
throw new DomainRuleException('Der Name der fachlichen Säule fehlt.');
}
return $name;
}
}