Skip to content

Commit ab6bac2

Browse files
Merge pull request #96 from akinoriakatsuka/feature/processors
Feature/processors
2 parents 8b302ba + 5607c9f commit ab6bac2

18 files changed

Lines changed: 2175 additions & 90 deletions
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Events;
4+
5+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\GroupChatId;
6+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\UserAccountId;
7+
use DateTimeImmutable;
8+
9+
readonly class GroupChatMemberRemoved implements GroupChatEvent {
10+
private string $id;
11+
private GroupChatId $aggregateId;
12+
private UserAccountId $memberUserAccountId;
13+
private UserAccountId $executorId;
14+
private int $sequenceNumber;
15+
private DateTimeImmutable $occurredAt;
16+
17+
public function __construct(
18+
string $id,
19+
GroupChatId $aggregateId,
20+
UserAccountId $memberUserAccountId,
21+
UserAccountId $executorId,
22+
int $sequenceNumber,
23+
DateTimeImmutable $occurredAt
24+
) {
25+
$this->id = $id;
26+
$this->aggregateId = $aggregateId;
27+
$this->memberUserAccountId = $memberUserAccountId;
28+
$this->executorId = $executorId;
29+
$this->sequenceNumber = $sequenceNumber;
30+
$this->occurredAt = $occurredAt;
31+
}
32+
33+
public function getId(): string {
34+
return $this->id;
35+
}
36+
37+
public function getTypeName(): string {
38+
return 'group-chat-member-removed';
39+
}
40+
41+
public function getSequenceNumber(): int {
42+
return $this->sequenceNumber;
43+
}
44+
45+
public function isCreated(): bool {
46+
return false;
47+
}
48+
49+
public function getOccurredAt(): DateTimeImmutable {
50+
return $this->occurredAt;
51+
}
52+
53+
public function getAggregateId(): GroupChatId {
54+
return $this->aggregateId;
55+
}
56+
57+
public function getMemberUserAccountId(): UserAccountId {
58+
return $this->memberUserAccountId;
59+
}
60+
61+
public function getExecutorId(): UserAccountId {
62+
return $this->executorId;
63+
}
64+
65+
public function jsonSerialize(): mixed {
66+
return [
67+
'id' => $this->id,
68+
'type' => $this->getTypeName(),
69+
'groupChatId' => $this->aggregateId,
70+
'memberUserAccountId' => $this->memberUserAccountId,
71+
'executorId' => $this->executorId,
72+
'sequenceNumber' => $this->sequenceNumber,
73+
'occurredAt' => $this->occurredAt->format(DATE_ATOM),
74+
];
75+
}
76+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
namespace Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Events;
4+
5+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\GroupChatId;
6+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\MessageId;
7+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\UserAccountId;
8+
use DateTimeImmutable;
9+
10+
readonly class GroupChatMessageDeleted implements GroupChatEvent {
11+
private string $id;
12+
private GroupChatId $groupChatId;
13+
private MessageId $messageId;
14+
private UserAccountId $executorId;
15+
private int $sequenceNumber;
16+
private DateTimeImmutable $occurredAt;
17+
18+
public function __construct(
19+
string $id,
20+
GroupChatId $groupChatId,
21+
MessageId $messageId,
22+
UserAccountId $executorId,
23+
int $sequenceNumber,
24+
DateTimeImmutable $occurredAt
25+
) {
26+
$this->id = $id;
27+
$this->groupChatId = $groupChatId;
28+
$this->messageId = $messageId;
29+
$this->executorId = $executorId;
30+
$this->sequenceNumber = $sequenceNumber;
31+
$this->occurredAt = $occurredAt;
32+
}
33+
34+
public function getId(): string {
35+
return $this->id;
36+
}
37+
38+
public function getTypeName(): string {
39+
return 'group-chat-message-deleted';
40+
}
41+
42+
public function getSequenceNumber(): int {
43+
return $this->sequenceNumber;
44+
}
45+
46+
public function isCreated(): bool {
47+
return false;
48+
}
49+
50+
public function getOccurredAt(): DateTimeImmutable {
51+
return $this->occurredAt;
52+
}
53+
54+
public function getAggregateId(): GroupChatId {
55+
return $this->groupChatId;
56+
}
57+
58+
public function getMessageId(): MessageId {
59+
return $this->messageId;
60+
}
61+
62+
public function getExecutorId(): UserAccountId {
63+
return $this->executorId;
64+
}
65+
66+
public function jsonSerialize(): mixed {
67+
return [
68+
'id' => $this->id,
69+
'type' => $this->getTypeName(),
70+
'groupChatId' => $this->groupChatId,
71+
'messageId' => $this->messageId,
72+
'executorId' => $this->executorId,
73+
'sequenceNumber' => $this->sequenceNumber,
74+
'occurredAt' => $this->occurredAt->format(DATE_ATOM),
75+
];
76+
}
77+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Events;
4+
5+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\GroupChatId;
6+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\MessageId;
7+
use Akinoriakatsuka\CqrsEsExamplePhp\Command\Domain\Models\UserAccountId;
8+
use DateTimeImmutable;
9+
10+
readonly class GroupChatMessageEdited implements GroupChatEvent {
11+
private string $id;
12+
private GroupChatId $groupChatId;
13+
private MessageId $messageId;
14+
private string $newText;
15+
private UserAccountId $executorId;
16+
private int $sequenceNumber;
17+
private DateTimeImmutable $occurredAt;
18+
19+
public function __construct(
20+
string $id,
21+
GroupChatId $groupChatId,
22+
MessageId $messageId,
23+
string $newText,
24+
UserAccountId $executorId,
25+
int $sequenceNumber,
26+
DateTimeImmutable $occurredAt
27+
) {
28+
$this->id = $id;
29+
$this->groupChatId = $groupChatId;
30+
$this->messageId = $messageId;
31+
$this->newText = $newText;
32+
$this->executorId = $executorId;
33+
$this->sequenceNumber = $sequenceNumber;
34+
$this->occurredAt = $occurredAt;
35+
}
36+
37+
public function getId(): string {
38+
return $this->id;
39+
}
40+
41+
public function getTypeName(): string {
42+
return 'group-chat-message-edited';
43+
}
44+
45+
public function getSequenceNumber(): int {
46+
return $this->sequenceNumber;
47+
}
48+
49+
public function isCreated(): bool {
50+
return false;
51+
}
52+
53+
public function getOccurredAt(): DateTimeImmutable {
54+
return $this->occurredAt;
55+
}
56+
57+
public function getAggregateId(): GroupChatId {
58+
return $this->groupChatId;
59+
}
60+
61+
public function getMessageId(): MessageId {
62+
return $this->messageId;
63+
}
64+
65+
public function getNewText(): string {
66+
return $this->newText;
67+
}
68+
69+
public function getExecutorId(): UserAccountId {
70+
return $this->executorId;
71+
}
72+
73+
public function jsonSerialize(): mixed {
74+
return [
75+
'id' => $this->id,
76+
'type' => $this->getTypeName(),
77+
'groupChatId' => $this->groupChatId,
78+
'messageId' => $this->messageId,
79+
'newText' => $this->newText,
80+
'executorId' => $this->executorId,
81+
'sequenceNumber' => $this->sequenceNumber,
82+
'occurredAt' => $this->occurredAt->format(DATE_ATOM),
83+
];
84+
}
85+
}

0 commit comments

Comments
 (0)