public function create(Dto $commentDto) : Dto { /** @var Comment $comment */ $comment = $this->dtoToEntityMapper->transform($commentDto); $this->commentRepository->add($comment); $this->systemWideEventDispatcher->dispatch(new CommentHasBeenAdded($comment->getAuthorsUsername(), $comment->getPostId())); foreach ($comment->getMentions() as $mention) { $this->systemWideEventDispatcher->dispatch(new UserHasBeenMentioned($comment->getAuthorsUsername(), $mention->getUsername(), $comment->getPostId())); } return $this->entityToDtoMapper->transform($comment); }