Lege einen wiederholbaren Pruefbestand fuer die Bibliothek an
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c99a957e6f
commit
abcdc6908e
3 files changed
+97
-1
No files matched your search
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SeedLibraryReview extends Command
|
||||
{
|
||||
protected $signature = 'library:review-fixture {--actor=}';
|
||||
|
||||
protected $description = 'Legt einmalig einen gekennzeichneten Prüfbestand für die Bibliothek an';
|
||||
|
||||
public function handle(
|
||||
ContentService $content,
|
||||
ArticleService $articles,
|
||||
OfferService $offers,
|
||||
CompositionDisplayRelease $display,
|
||||
): int {
|
||||
$existing = Composition::query()->where('designation', 'Prüfprogramm Abstand')->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
$this->info('Prüfbestand ist bereits vorhanden.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$actor = User::query()->find($this->option('actor')) ?? User::query()->orderBy('id')->first();
|
||||
|
||||
if ($actor === null) {
|
||||
$this->error('Es gibt kein Konto, das die Anzeigefreigabe zeichnen kann.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
|
||||
|
||||
if ($kind === null) {
|
||||
$this->error('Die Inhaltsart Programm fehlt.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$sheet = $content->publishElementVersion(
|
||||
$content->createElement('text', 'document', 'Prüfblatt Abstand'),
|
||||
'Gekennzeichneter Prüftext. Kein Veröffentlichungstext.',
|
||||
);
|
||||
$composition = $content->createComposition('Prüfprogramm Abstand');
|
||||
$composition->editorial_content_kind_id = $kind->id;
|
||||
$composition->display_title = 'Prüfprogramm Abstand';
|
||||
$composition->summary = 'Gekennzeichneter Prüfbestand für die Testinstanz.';
|
||||
$composition->thumbnail_error = 'Prüfhinweis: kein Vorschaubild.';
|
||||
$composition->save();
|
||||
$version = $content->publishComposition($composition, [
|
||||
['role' => 'Blatt', 'target' => $sheet],
|
||||
], $actor, 'Prüfbestand', [
|
||||
'learning_goal' => 'Den Prüfaufbau in der Bibliothek sehen.',
|
||||
'duration_minutes' => 5,
|
||||
'material_note' => 'Nur der Prüftext.',
|
||||
]);
|
||||
$article = $articles->create('pruef-abstand');
|
||||
$articles->publishRelease($article, $version, 'Prüffassung.');
|
||||
$rights = $offers->createRightsProfile('Prüfblatt ansehen', 'ehrenamtlich', [
|
||||
'document' => ['ansehen', 'laden'],
|
||||
]);
|
||||
$offer = $offers->create('Prüfprogramm Abstand');
|
||||
$offers->activate($offer, [
|
||||
['target' => $article->fresh(), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf', 'composition_version_id' => $version->id]);
|
||||
$display->release($version, $actor, 'Prüffreigabe');
|
||||
$this->info('Prüfbestand angelegt. Angebot: Prüfprogramm Abstand.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user