Lasse Präsentationsmedien ohne Inhaltsfassung zu.
CI Feature / test (push) Successful in 53s
Deploy Test / test (push) Successful in 48s
Deploy Test / deploy (push) Successful in 22s

Bilder, Filme und Hörstücke lassen sich zuordnen und für die Website freigeben, ohne eine fachliche Fassung anzulegen. Unterrichtsfilme behalten die Teaserfassung an ihrer bereitgestellten Fassung.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-19 08:20:35 +01:00
1 parent 5590225f4f
commit 7b325f0d66
25 files changed
+734 -93

No files matched your search

+1
View File
@@ -28,6 +28,7 @@ class ContentElement extends Model
'thumbnail_alt',
'thumbnail_source',
'thumbnail_error',
'preview_path',
'editorial_content_kind_id',
'archived_at',
];
+29
View File
@@ -2,6 +2,7 @@
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -13,4 +14,32 @@ public function values(): HasMany
{
return $this->hasMany(EditorialDimensionValue::class);
}
/**
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension.
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension.
*
* @return Collection<int, self>
*/
public static function forSubject(Model $subject): Collection
{
$query = static::query()->with('values')->orderBy('label');
if ($subject instanceof ContentElement) {
$query->where('slug', '!=', 'saeule');
}
return $query->get();
}
/**
* @return list<int>
*/
public static function offeredValueIds(Model $subject): array
{
return static::forSubject($subject)
->flatMap(fn (self $dimension) => $dimension->values->pluck('id'))
->map(fn ($id): int => (int) $id)
->all();
}
}
+31
View File
@@ -52,4 +52,35 @@ public function matches(Model $subject, array $valueIds): bool
return true;
}
/**
* Ersetzt nur die Werte der Dimensionen, die dieses Fachobjekt anbietet.
* Nicht angebotene Zuordnungen, etwa gespiegelte Säulen am Inhaltselement, bleiben.
*
* @param list<int> $valueIds
*/
public function replaceOffered(Model $subject, array $valueIds): void
{
$offeredIds = EditorialDimension::offeredValueIds($subject);
$ids = array_values(array_intersect(
array_values(array_unique(array_map(intval(...), $valueIds))),
$offeredIds,
));
$query = IdentityDimensionValue::query()
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->where('origin', 'direkt')
->whereIn('editorial_dimension_value_id', $offeredIds === [] ? [0] : $offeredIds);
if ($ids !== []) {
$query->whereNotIn('editorial_dimension_value_id', $ids);
}
$query->delete();
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
$this->assign($subject, $value, 'direkt');
}
}
}