54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http;
|
|
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
|
|
class CourseOutline
|
|
{
|
|
public function title(LicenseArticle $article): string
|
|
{
|
|
$release = $article->currentRelease;
|
|
|
|
if ($release === null) {
|
|
return $article->code;
|
|
}
|
|
|
|
$release->loadMissing([
|
|
'rootCompositionVersion.composition',
|
|
'rootElementVersion.element',
|
|
]);
|
|
|
|
return $release->rootCompositionVersion?->composition?->designation
|
|
?? $release->rootElementVersion?->element?->working_title
|
|
?? $release->classification_note
|
|
?? $article->code;
|
|
}
|
|
|
|
public function kindLabel(LicenseArticle $article): ?string
|
|
{
|
|
$release = $article->currentRelease;
|
|
|
|
if ($release === null) {
|
|
return null;
|
|
}
|
|
|
|
$release->loadMissing([
|
|
'rootCompositionVersion.composition.editorialContentKind',
|
|
'rootElementVersion.element.editorialContentKind',
|
|
]);
|
|
|
|
$editorial = $release->rootCompositionVersion?->composition?->editorialContentKind?->label
|
|
?? $release->rootElementVersion?->element?->editorialContentKind?->label;
|
|
|
|
if ($editorial !== null) {
|
|
return $editorial;
|
|
}
|
|
|
|
$kind = $release->rootCompositionVersion?->composition?->kind;
|
|
|
|
return $kind instanceof CompositionKind ? $kind->label() : null;
|
|
}
|
|
}
|