activity: avoid existing entities being added in Users, ThirdParties, Persons

This commit is contained in:
juminet
2021-11-29 12:27:54 +00:00
committed by Julien Fastré
parent 58119b3de0
commit b300858bdd
18 changed files with 277 additions and 94 deletions

View File

@@ -9,6 +9,7 @@
namespace Chill\ActivityBundle\Entity;
use Chill\ActivityBundle\Validator\Constraints as ActivityValidator;
use Chill\DocStoreBundle\Entity\Document;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
@@ -41,6 +42,7 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
* @DiscriminatorMap(typeProperty="type", mapping={
* "activity": Activity::class
* })
* @ActivityValidator\ActivityValidity
*/
/*
@@ -202,7 +204,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addPerson(?Person $person): self
{
if (null !== $person) {
$this->persons[] = $person;
if (!$this->persons->contains($person)) {
$this->persons[] = $person;
}
}
return $this;
@@ -236,7 +240,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addThirdParty(?ThirdParty $thirdParty): self
{
if (null !== $thirdParty) {
$this->thirdParties[] = $thirdParty;
if (!$this->thirdParties->contains($thirdParty)) {
$this->thirdParties[] = $thirdParty;
}
}
return $this;
@@ -245,7 +251,9 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
public function addUser(?User $user): self
{
if (null !== $user) {
$this->users[] = $user;
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
}
return $this;