Д
Size: a a a
Д
СП
Д
a
В
В
СП
В
В
СП
В
AM
В
interface DeferredEventService {
public function pushEvent(object $event): void;
public function releaseEvents(): void;
}
AM
AM
СП
interface DeferredEventService {
public function pushEvent(object $event): void;
public function releaseEvents(): void;
}
В
AM
В
final class CommentService
{
private CommentRepositoryInterface $commentRepository;
private DeferredEventService $eventService;
public function create(string $threadId, string $userId, string $body, ?string $byUserId = null): Comment
{
$this->eventService->pushEvent(new EventBefore());
$comment = new Comment(
UuidHelper::generateTimestampFirstCombUuid4(),
$thread->getId(),
$userId,
$body,
$byUserId,
);
$this->eventService->pushEvent(new EventInside());
$this->commentRepository->save($comment);
$this->eventService->pushEvent(new EventAfter());
$this->eventService->releaseEvents();
return $comment;
}
}
a