AM
Я так понимаю, этот трейт исключительно для накопления эвентов, а их отправка в диспетчер должна вручную осуществляться?
Size: a a a
AM
В
$value = $entity->getValue();
$entity->setValue($newValue);
$entity->setValue($value);
СП
СП
final class CommentService
{
private CommentRepositoryInterface $commentRepository;
private EventDispatcherInterface $eventDispatcher;
...
public function create(string $threadId, string $userId, string $body, ?string $byUserId = null): Comment
{
...
$comment = new Comment(
UuidHelper::generateTimestampFirstCombUuid4(),
$thread->getId(),
$userId,
$body,
$byUserId,
);
$this->commentRepository->save($comment);
$this->releaseEvents($comment);
return $comment;
}
...
private function releaseEvents(Comment $comment): void
{
foreach ($comment->releaseEvents() as $event) {
$this->eventDispatcher->dispatch($event);
}
}
}
a
В
final class CommentService
{
private CommentRepositoryInterface $commentRepository;
private EventDispatcherInterface $eventDispatcher;
...
public function create(string $threadId, string $userId, string $body, ?string $byUserId = null): Comment
{
...
$comment = new Comment(
UuidHelper::generateTimestampFirstCombUuid4(),
$thread->getId(),
$userId,
$body,
$byUserId,
);
$this->commentRepository->save($comment);
$this->releaseEvents($comment);
return $comment;
}
...
private function releaseEvents(Comment $comment): void
{
foreach ($comment->releaseEvents() as $event) {
$this->eventDispatcher->dispatch($event);
}
}
}
СП
В
В
public function create(string $threadId, string $userId, string $body, ?string $byUserId = null)
СП
public function create(string $threadId, string $userId, string $body, ?string $byUserId = null)
В
В
СП
В
СП
В
СП
СП
В