Skip to content

Commit

Permalink
Fix constructor call
Browse files Browse the repository at this point in the history
  • Loading branch information
quentint committed Mar 6, 2023
1 parent 8ca22ce commit 8be8e14
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Service/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace eduMedia\CommentBundle\Service;

use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
Expand All @@ -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
Expand Down

0 comments on commit 8be8e14

Please sign in to comment.