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;
|
||||
|
@@ -12,6 +12,7 @@ namespace Chill\ActivityBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Class ActivityType.
|
||||
@@ -29,11 +30,13 @@ class ActivityType
|
||||
public const FIELD_REQUIRED = 2;
|
||||
|
||||
/**
|
||||
* @deprecated not in use
|
||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||
*/
|
||||
private string $accompanyingPeriodLabel = '';
|
||||
|
||||
/**
|
||||
* @deprecated not in use
|
||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||
*/
|
||||
private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE;
|
||||
@@ -195,16 +198,21 @@ class ActivityType
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||
* @Assert\EqualTo(propertyPath="socialIssuesVisible", message="This parameter must be equal to social issue parameter")
|
||||
*/
|
||||
private int $socialActionsVisible = self::FIELD_INVISIBLE;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||
*
|
||||
* @deprecated not in use
|
||||
*/
|
||||
private string $socialDataLabel = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||
*
|
||||
* @deprecated not in use
|
||||
*/
|
||||
private int $socialDataVisible = self::FIELD_INVISIBLE;
|
||||
|
||||
@@ -260,16 +268,6 @@ class ActivityType
|
||||
*/
|
||||
private int $userVisible = self::FIELD_REQUIRED;
|
||||
|
||||
public function getAccompanyingPeriodLabel(): string
|
||||
{
|
||||
return $this->accompanyingPeriodLabel;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriodVisible(): int
|
||||
{
|
||||
return $this->accompanyingPeriodVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active
|
||||
* return true if the type is active.
|
||||
@@ -446,16 +444,6 @@ class ActivityType
|
||||
return $this->socialActionsVisible;
|
||||
}
|
||||
|
||||
public function getSocialDataLabel(): string
|
||||
{
|
||||
return $this->socialDataLabel;
|
||||
}
|
||||
|
||||
public function getSocialDataVisible(): int
|
||||
{
|
||||
return $this->socialDataVisible;
|
||||
}
|
||||
|
||||
public function getSocialIssuesLabel(): ?string
|
||||
{
|
||||
return $this->socialIssuesLabel;
|
||||
@@ -537,20 +525,6 @@ class ActivityType
|
||||
return self::FIELD_INVISIBLE !== $this->{$property};
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): self
|
||||
{
|
||||
$this->accompanyingPeriodLabel = $accompanyingPeriodLabel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): self
|
||||
{
|
||||
$this->accompanyingPeriodVisible = $accompanyingPeriodVisible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active
|
||||
* set to true if the type is active.
|
||||
@@ -768,20 +742,6 @@ class ActivityType
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSocialDataLabel(string $socialDataLabel): self
|
||||
{
|
||||
$this->socialDataLabel = $socialDataLabel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSocialDataVisible(int $socialDataVisible): self
|
||||
{
|
||||
$this->socialDataVisible = $socialDataVisible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSocialIssuesLabel(string $socialIssuesLabel): self
|
||||
{
|
||||
$this->socialIssuesLabel = $socialIssuesLabel;
|
||||
|
Reference in New Issue
Block a user