CI Feature / test (push) Successful in 2m34s
Eigener Eintrag Übungen unter Inhalte (Bestand, Anlegen, gemeinsamer Aufbau mit Varianten, Verwendung und Variantenauswahl im Modul und Programm), Verwendungsnachweis über verschachtelte und ältere Stände, Auswirkungsbericht einer Mediensperre, gesperrte Bestandteile verhindern die Angebotsaktivierung, Vorschaubilder gesperrter Medien werden nicht mehr ausgeliefert, Rückfalltest gegen die Daten des neuen Stands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
class OfferCoverage
|
|
{
|
|
public function __construct(private readonly ContentResolver $resolver) {}
|
|
|
|
/**
|
|
* Bestandteile der Fassung, deren Medienfassung gesperrt ist. Ein Angebot soll nicht aktiviert werden, solange sein
|
|
* Umfang gesperrte Bestandteile enthält; die Prüfung nennt sie vorab.
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
public function blockedLeaves(CompositionVersion $version): array
|
|
{
|
|
$rows = $this->resolver->expand($version);
|
|
$blocked = ContentElementVersion::query()
|
|
->whereIn('id', array_column($rows, 'version_id'))
|
|
->where('status', ContentVersionStatus::Gesperrt->value)
|
|
->pluck('id')
|
|
->all();
|
|
|
|
return array_values(array_map(
|
|
fn (array $row): string => $row['path'],
|
|
array_filter($rows, fn (array $row): bool => in_array($row['version_id'], $blocked, true)),
|
|
));
|
|
}
|
|
|
|
/**
|
|
* @param list<LicenseArticle> $articles
|
|
* @return list<string>
|
|
*/
|
|
public function missingLeaves(CompositionVersion $version, array $articles): array
|
|
{
|
|
$covered = [];
|
|
|
|
foreach ($articles as $article) {
|
|
$release = $article->currentRelease;
|
|
if ($release === null) {
|
|
continue;
|
|
}
|
|
|
|
foreach ($release->contents()->pluck('content_element_version_id') as $id) {
|
|
$covered[(int) $id] = true;
|
|
}
|
|
}
|
|
|
|
$missing = [];
|
|
|
|
foreach ($this->resolver->expand($version) as $row) {
|
|
if (! isset($covered[$row['version_id']])) {
|
|
$missing[] = $row['path'];
|
|
}
|
|
}
|
|
|
|
return $missing;
|
|
}
|
|
}
|