add merge method

This commit is contained in:
Julie Lenaerts 2022-05-02 14:01:41 +02:00
parent c629dd79cb
commit acee0ade24
2 changed files with 18 additions and 2 deletions

View File

@ -41,4 +41,20 @@ class PrivateCommentEmbeddable
return $this;
}
public function setComments($comments)
{
$this->comments = $comments;
return $this;
}
public function merge(PrivateCommentEmbeddable $newComment): self
{
$mergedComments = $newComment->getComments() + $this->getComments();
$this->setComments($mergedComments);
return $this;
}
}

View File

@ -138,7 +138,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
* @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"})
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
*/
private PrivateCommentEmbeddable $privateComment;
@ -521,7 +521,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
{
$this->privateComment = $privateComment;
$this->privateComment->merge($privateComment);
return $this;
}