feat: add logic to sync drafts to server
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KTXM\Mail;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use KTXF\Event\Event;
|
||||
|
||||
final class CompositionSavedEvent extends Event {
|
||||
|
||||
public function __construct(
|
||||
string $tenantId,
|
||||
private readonly string $userId,
|
||||
private readonly string $compositionId,
|
||||
private readonly int $revision,
|
||||
) {
|
||||
if ($tenantId === '' || $this->userId === '' || $this->compositionId === '') {
|
||||
throw new InvalidArgumentException('Composition save events require tenant, user, and composition identifiers');
|
||||
}
|
||||
if ($this->revision < 0) {
|
||||
throw new InvalidArgumentException('Composition save event revision cannot be negative');
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
self::class,
|
||||
[
|
||||
'userId' => $this->userId,
|
||||
'compositionId' => $this->compositionId,
|
||||
'revision' => $this->revision,
|
||||
],
|
||||
$tenantId,
|
||||
$this->userId,
|
||||
);
|
||||
}
|
||||
|
||||
public function userIdentifier(): string {
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
public function compositionIdentifier(): string {
|
||||
return $this->compositionId;
|
||||
}
|
||||
|
||||
public function revision(): int {
|
||||
return $this->revision;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user