mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
improvements on private comments
This commit is contained in:
@@ -20,15 +20,22 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
class PrivateCommentEmbeddable
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
* @ORM\Column(type="json", nullable=false, options={"default": "{}"})
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private ?array $comments = [];
|
||||
private array $comments = [];
|
||||
|
||||
public function getCommentForUser(User $user): string
|
||||
{
|
||||
return $this->comments[$user->getId()] ?? '';
|
||||
}
|
||||
|
||||
public function hasCommentForUser(User $user): bool
|
||||
{
|
||||
return array_key_exists($user->getId(), $this->comments)
|
||||
&& "" !== $this->comments[$user->getId()];
|
||||
}
|
||||
|
||||
public function getComments(): ?array
|
||||
{
|
||||
return $this->comments;
|
||||
@@ -47,7 +54,7 @@ class PrivateCommentEmbeddable
|
||||
|
||||
public function setCommentForUser(User $user, string $content): self
|
||||
{
|
||||
$this->comments[$user->getId()] = $content;
|
||||
$this->comments[$user->getId()] = trim($content);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user