diff --git a/src/Service/CommentService.php b/src/Service/CommentService.php index 2286586..5cfa4fb 100644 --- a/src/Service/CommentService.php +++ b/src/Service/CommentService.php @@ -2,6 +2,7 @@ namespace eduMedia\CommentBundle\Service; +use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; @@ -23,7 +24,10 @@ public function __construct( public function createComment(string $content): CommentInterface { - return new $this->commentClass($content); + /** @var CommentInterface $comment */ + $comment = new $this->commentClass(); + + return ($comment)->setCreatedAt(new DateTimeImmutable())->setContent($content); } public function getComments(CommentableInterface $resource, bool $autoload = false): Collection