Benenne Medien ohne Anzeigenamen nach ihrem Arbeitstitel
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
4520dba2f0
commit
9701777011
3 files changed
+40
-7
No files matched your search
@@ -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 '';
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user