Sfoglia il codice sorgente

add some missing relations to entities

Olivier Massot 1 anno fa
parent
commit
ccfbd9d3af

+ 42 - 0
src/Entity/Core/File.php

@@ -10,10 +10,12 @@ use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\Metadata\Put;
 use App\Entity\AccessWish\DocumentWish;
+use App\Entity\Booking\CalendarSynchro;
 use App\Entity\Booking\Event;
 use App\Entity\Booking\EventReport;
 use App\Entity\Booking\Work;
 use App\Entity\Message\TemplateSystem;
+use App\Entity\Network\Network;
 use App\Entity\Organization\Activity;
 use App\Entity\Organization\OnlineRegistrationSettings;
 use App\Entity\Organization\Organization;
@@ -231,6 +233,12 @@ class File
     #[ORM\JoinColumn(onDelete: 'CASCADE')]
     private TemplateSystem $templateSystem;
 
+    #[ORM\OneToMany(mappedBy: 'image', targetEntity: Network::class)]
+    private Collection $networks;
+
+    #[ORM\OneToOne(targetEntity: CalendarSynchro::class, mappedBy: 'file')]
+    private CalendarSynchro $calendarSynchro;
+
     #[Pure]
     public function __construct()
     {
@@ -241,6 +249,7 @@ class File
         $this->events = new ArrayCollection();
         $this->activityLogos = new ArrayCollection();
         $this->activityImages = new ArrayCollection();
+        $this->networks = new ArrayCollection();
     }
 
     public function getId(): ?int
@@ -738,4 +747,37 @@ class File
 
         return $this;
     }
+
+    public function getNetworks(): Collection
+    {
+        return $this->networks;
+    }
+
+    public function addNetwork(Network $network): self
+    {
+        if (!$this->networks->contains($network)) {
+            $this->networks[] = $network;
+            $network->setImage($this);
+        }
+
+        return $this;
+    }
+
+    public function removeNetwork(Network $network): self
+    {
+        $this->networks->removeElement($network);
+
+        return $this;
+    }
+
+    public function getCalendarSynchro(): CalendarSynchro
+    {
+        return $this->calendarSynchro;
+    }
+
+    public function setCalendarSynchro(CalendarSynchro $calendarSynchro): self
+    {
+        $this->calendarSynchro = $calendarSynchro;
+        return $this;
+    }
 }

+ 59 - 0
src/Entity/Person/AllowedIp.php

@@ -0,0 +1,59 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Entity\Person;
+
+use ApiPlatform\Metadata\ApiResource;
+use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+
+#[ApiResource(operations: [])]
+#[ORM\Entity]
+class AllowedIp
+{
+    #[ORM\Id]
+    #[ORM\Column]
+    #[ORM\GeneratedValue]
+    private int $id;
+
+    #[Assert\NotNull]
+    #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'allowedIps')]
+    private Person $person;
+
+    #[ORM\Column(type: 'string', nullable: true)]
+    private string $ipOrRange;
+
+    public function getId(): int
+    {
+        return $this->id;
+    }
+
+    public function setId(int $id): self
+    {
+        $this->id = $id;
+        return $this;
+    }
+
+    public function getPerson(): Person
+    {
+        return $this->person;
+    }
+
+    public function setPerson(Person $person): self
+    {
+        $this->person = $person;
+        return $this;
+    }
+
+    public function getIpOrRange(): string
+    {
+        return $this->ipOrRange;
+    }
+
+    public function setIpOrRange(string $ipOrRange)
+    {
+        $this->ipOrRange = $ipOrRange;
+        return $this;
+    }
+}

+ 14 - 0
src/Entity/Person/Medical.php

@@ -19,8 +19,22 @@ class Medical
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
+    #[ORM\OneToOne(mappedBy: 'medical', targetEntity: Person::class, cascade: ['persist'], orphanRemoval: true)]
+    private Person $person;
+
     public function getId(): ?int
     {
         return $this->id;
     }
+
+    public function getPerson(): Person
+    {
+        return $this->person;
+    }
+
+    public function setPerson(Person $person): self
+    {
+        $this->person = $person;
+        return $this;
+    }
 }

+ 38 - 0
src/Entity/Person/Person.php

@@ -103,6 +103,12 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\OneToMany(mappedBy: 'personOwner', targetEntity: DocumentWish::class, cascade: ['persist'], orphanRemoval: true)]
     private Collection $documentWishes;
 
+    #[ORM\OneToOne(targetEntity: Medical::class, inversedBy: 'person', cascade: ['persist'])]
+    private Medical $medical;
+
+    #[ORM\OneToMany(targetEntity: AllowedIp::class, mappedBy: 'person', cascade: ['persist'], orphanRemoval: true)]
+    private Collection $allowedIps;
+
     #[Pure]
     public function __construct()
     {
@@ -588,4 +594,36 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
 
         return $this;
     }
+
+    public function getMedical(): Medical
+    {
+        return $this->medical;
+    }
+
+    public function setMedical(Medical $medical): self
+    {
+        $this->medical = $medical;
+        return $this;
+    }
+
+    public function getAllowedIps(): Collection
+    {
+        return $this->allowedIps;
+    }
+
+    public function addAllowedIp(AllowedIp $allowedIp): self
+    {
+        if (!$this->allowedIps->contains($allowedIp)) {
+            $this->allowedIps[] = $allowedIp;
+            $allowedIp->setPerson($this);
+        }
+
+        return $this;
+    }
+
+    public function removeAllowedIp(AllowedIp $allowedIp): self
+    {
+        $this->allowedIps->removeElement($allowedIp);
+        return $this;
+    }
 }