From acee0ade24dec7de24ee6e2c1c9e8d80bbeb7c93 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 2 May 2022 14:01:41 +0200 Subject: [PATCH] add merge method --- .../Embeddable/PrivateCommentEmbeddable.php | 16 ++++++++++++++++ .../AccompanyingPeriodWork.php | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php index 70374749c..f3e35bb1f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php +++ b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php @@ -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; + } } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index fd1156e01..8ea1028f8 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -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; }