|
@@ -13,6 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
|
+use App\Validator\Core as OpentalentAssert;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Données de contact d'une Person ou d'une Organization ou d'un lieu
|
|
* Données de contact d'une Person ou d'une Organization ou d'un lieu
|
|
@@ -31,6 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|
|
]
|
|
]
|
|
|
)]
|
|
)]
|
|
|
#[ORM\Entity(repositoryClass: ContactPointRepository::class)]
|
|
#[ORM\Entity(repositoryClass: ContactPointRepository::class)]
|
|
|
|
|
+#[OpentalentAssert\ContactPoint]
|
|
|
class ContactPoint
|
|
class ContactPoint
|
|
|
{
|
|
{
|
|
|
#[ORM\Id]
|
|
#[ORM\Id]
|
|
@@ -69,10 +71,14 @@ class ContactPoint
|
|
|
|
|
|
|
|
#[ORM\ManyToMany(targetEntity: Organization::class, inversedBy: 'contactPoints')]
|
|
#[ORM\ManyToMany(targetEntity: Organization::class, inversedBy: 'contactPoints')]
|
|
|
#[ORM\JoinTable(name: 'organization_contactpoint')]
|
|
#[ORM\JoinTable(name: 'organization_contactpoint')]
|
|
|
|
|
+ #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
|
|
|
|
|
+ #[ORM\InverseJoinColumn(name: 'organization_id', referencedColumnName: 'id')]
|
|
|
private Collection $organization;
|
|
private Collection $organization;
|
|
|
|
|
|
|
|
#[ORM\ManyToMany(targetEntity: Person::class ,inversedBy: 'contactPoints')]
|
|
#[ORM\ManyToMany(targetEntity: Person::class ,inversedBy: 'contactPoints')]
|
|
|
#[ORM\JoinTable(name: 'person_contactpoint')]
|
|
#[ORM\JoinTable(name: 'person_contactpoint')]
|
|
|
|
|
+ #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
|
|
|
|
|
+ #[ORM\InverseJoinColumn(name: 'person_id', referencedColumnName: 'id')]
|
|
|
private Collection $person;
|
|
private Collection $person;
|
|
|
|
|
|
|
|
#[Pure] public function __construct()
|
|
#[Pure] public function __construct()
|
|
@@ -215,6 +221,7 @@ class ContactPoint
|
|
|
{
|
|
{
|
|
|
if (!$this->organization->contains($organization)) {
|
|
if (!$this->organization->contains($organization)) {
|
|
|
$this->organization[] = $organization;
|
|
$this->organization[] = $organization;
|
|
|
|
|
+ $organization->addContactPoint($this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
return $this;
|
|
@@ -222,8 +229,18 @@ class ContactPoint
|
|
|
|
|
|
|
|
public function removeOrganization(Organization $organization): self
|
|
public function removeOrganization(Organization $organization): self
|
|
|
{
|
|
{
|
|
|
- $this->organization->removeElement($organization);
|
|
|
|
|
|
|
+ if ($this->organization->removeElement($organization)) {
|
|
|
|
|
+ $organization->removeContactPoint($this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ public function removeOrganizations(): self
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach ($this->getOrganization() as $organization){
|
|
|
|
|
+ $this->removeOrganization($organization);
|
|
|
|
|
+ }
|
|
|
return $this;
|
|
return $this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -236,6 +253,7 @@ class ContactPoint
|
|
|
{
|
|
{
|
|
|
if (!$this->person->contains($person)) {
|
|
if (!$this->person->contains($person)) {
|
|
|
$this->person[] = $person;
|
|
$this->person[] = $person;
|
|
|
|
|
+ $person->addContactPoint($this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
return $this;
|
|
@@ -243,8 +261,18 @@ class ContactPoint
|
|
|
|
|
|
|
|
public function removePerson(Person $person): self
|
|
public function removePerson(Person $person): self
|
|
|
{
|
|
{
|
|
|
- $this->person->removeElement($person);
|
|
|
|
|
|
|
+ if ($this->person->removeElement($person)) {
|
|
|
|
|
+ $person->removeContactPoint($this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ public function removePeople(): self
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach ($this->getPerson() as $person){
|
|
|
|
|
+ $this->removePerson($person);
|
|
|
|
|
+ }
|
|
|
return $this;
|
|
return $this;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|