mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
activity: avoid existing entities being added in Users, ThirdParties, Persons
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user