MVP 1.2 (inkl. Shop) #3

Merged
Lars merged 47 commits from develop into main 2026-11-22 11:43:02 +01:00
3 changed files with 40 additions and 7 deletions
Showing only changes of commit 9701777011 - Show all commits

No files matched your search

+24 -3
View File
@@ -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();