From 9701777011560aaf6b98ab2d50e58b54e6cb501f Mon Sep 17 00:00:00 2001 From: Stommer Date: Sat, 21 Nov 2026 18:37:58 +0100 Subject: [PATCH] Benenne Medien ohne Anzeigenamen nach ihrem Arbeitstitel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Name eines Lizenzartikels fällt auf den Arbeitstitel oder die Bezeichnung des Inhalts zurück, bevor die Kennung erscheint. Das Begleitmaterial zeigte im Shop sonst die Kennung. Co-Authored-By: Claude Sonnet 5.5 --- app/Domain/Commerce/ProductOptions.php | 27 ++++++++++++++++--- app/Filament/Support/PublicationReadiness.php | 6 ++--- tests/Feature/ShopVerwaltungAbnahmeTest.php | 14 ++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/app/Domain/Commerce/ProductOptions.php b/app/Domain/Commerce/ProductOptions.php index b6cb811..dbff0d5 100644 --- a/app/Domain/Commerce/ProductOptions.php +++ b/app/Domain/Commerce/ProductOptions.php @@ -110,9 +110,30 @@ public function articleTitle(?LicenseArticle $article): string return '–'; } - // Wie in der Redaktion: eigener Name, sonst der Name des Inhalts, zuletzt die Kennung. - $name = app(EditorialProfileReader::class)->read($article, 'detail')->value('display_title'); + return $this->articleName($article) ?: (string) $article->code; + } - return (string) (filled($name) ? $name : ($article->working_title ?: $article->code)); + /** + * Name wie in der Redaktion: eigener Name, sonst der Name des Inhalts (Anzeigename, Arbeitstitel oder + * Bezeichnung), sonst der eigene Arbeitstitel; leer, wenn nichts davon vorhanden ist. + */ + public function articleName(LicenseArticle $article): string + { + $profile = app(EditorialProfileReader::class)->read($article, 'detail'); + $source = $profile->source; + $candidates = [ + $profile->value('display_title'), + $article->working_title, + $source?->getAttribute('working_title'), + $source?->getAttribute('designation'), + ]; + + foreach ($candidates as $candidate) { + if (filled($candidate)) { + return trim((string) $candidate); + } + } + + return ''; } } diff --git a/app/Filament/Support/PublicationReadiness.php b/app/Filament/Support/PublicationReadiness.php index 9339db2..94c5953 100644 --- a/app/Filament/Support/PublicationReadiness.php +++ b/app/Filament/Support/PublicationReadiness.php @@ -8,7 +8,6 @@ use App\Domain\Catalog\BundleStatus; use App\Domain\Catalog\BundleVersion; use App\Domain\Catalog\DomainRuleException; -use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\Offer; use App\Domain\Catalog\OfferService; @@ -17,6 +16,7 @@ use App\Domain\Catalog\StatusValue; use App\Domain\Cms\Catalog\PublicCatalogReader; use App\Domain\Commerce\Money; +use App\Domain\Commerce\ProductOptions; use App\Filament\Resources\LicenseArticles\LicenseArticleResource; use App\Filament\Resources\Offers\OfferResource; use Illuminate\Support\Facades\DB; @@ -62,9 +62,7 @@ public function articleLabel(LicenseArticle $article): string /** Name wie in der Redaktion: eigener Name oder Name des Inhalts, sonst der Arbeitstitel; leer ohne beides. */ public function articleName(LicenseArticle $article): string { - $name = app(EditorialProfileReader::class)->read($article, 'artikel')->value('display_title'); - - return trim((string) (filled($name) ? $name : $article->working_title)); + return app(ProductOptions::class)->articleName($article); } /** diff --git a/tests/Feature/ShopVerwaltungAbnahmeTest.php b/tests/Feature/ShopVerwaltungAbnahmeTest.php index 3900581..14397fd 100644 --- a/tests/Feature/ShopVerwaltungAbnahmeTest.php +++ b/tests/Feature/ShopVerwaltungAbnahmeTest.php @@ -5,6 +5,8 @@ use App\Domain\Catalog\ArticleService; use App\Domain\Catalog\BundleService; use App\Domain\Catalog\Composition; +use App\Domain\Catalog\ContentElement; +use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentService; use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\OfferService; @@ -221,6 +223,18 @@ public function test_the_scope_names_an_article_by_its_content_and_not_by_its_co $this->assertStringContainsString('Grenzen setzen im Verein (nur-kennung-abnahme) · Stand 1', app(PublicationReadiness::class)->articleOptions()[$article->id]); } + public function test_a_medium_without_display_title_names_its_article_by_the_working_title(): void + { + $element = ContentElement::query()->where('working_title', 'Begleitmaterial Grenzen setzen im Verein')->firstOrFail(); + $version = ContentElementVersion::query()->where('content_element_id', $element->id)->firstOrFail(); + $article = app(ArticleService::class)->create('nur-kennung-medium'); + app(ArticleService::class)->publishRelease($article, $version, 'Erster Stand dieses Lizenzartikels.'); + + $this->assertSame('Begleitmaterial Grenzen setzen im Verein', app(ProductOptions::class)->articleTitle($article->refresh())); + $this->assertSame('Begleitmaterial Grenzen setzen im Verein', app(PublicationReadiness::class)->articleName($article)); + $this->assertSame('nur-kennung-ohne-inhalt', app(ProductOptions::class)->articleTitle(app(ArticleService::class)->create('nur-kennung-ohne-inhalt')), 'Ohne Namen bleibt die Kennung.'); + } + private function rights(): RightsProfileVersion { return RightsProfileVersion::query()->orderBy('id')->firstOrFail();