37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Media;
|
|
|
|
use App\Domain\Catalog\ArticleRelease;
|
|
use App\Domain\Catalog\ContentElementVersion;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
use App\Domain\Entitlement\Grant;
|
|
use App\Domain\Entitlement\MediaDelivery;
|
|
|
|
class DeliveryLog
|
|
{
|
|
public function write(
|
|
Grant $grant,
|
|
LicenseArticle $article,
|
|
ArticleRelease $release,
|
|
ContentElementVersion $version,
|
|
string $action,
|
|
string $format,
|
|
?string $checksum,
|
|
string $marking,
|
|
): MediaDelivery {
|
|
return MediaDelivery::query()->create([
|
|
'grant_id' => $grant->id,
|
|
'license_article_id' => $article->id,
|
|
'article_release_id' => $release->id,
|
|
'content_element_version_id' => $version->id,
|
|
'action' => $action,
|
|
'format' => $format,
|
|
'copy_id' => 'LK-'.strtoupper(bin2hex(random_bytes(6))),
|
|
'checksum' => $checksum,
|
|
'marking' => $marking,
|
|
'delivered_at' => now(),
|
|
]);
|
|
}
|
|
}
|