src/Entity/Engagement/EngagementProjet.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Engagement;
  3. use App\Entity\Project;
  4. use App\Repository\EngagementProjetRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Annotation\CustomAnnotation;
  9. /**
  10.  * @ORM\Entity(repositoryClass=EngagementProjetRepository::class)
  11.  */
  12. class EngagementProjet
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="\App\Entity\Project", cascade={"persist"})
  22.      * @ORM\JoinColumn(name="project_id", referencedColumnName="id",nullable=true,onDelete="SET NULL")
  23.      * @CustomAnnotation("Projet")
  24.      */
  25.     private $projet;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity="EngagementVersion",mappedBy="engagementProjet", cascade={"persist"})
  28.      */
  29.     private $engagementVersion;
  30.     public function __construct()
  31.     {
  32.         $this->engagementVersion = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getProjet(): ?Project
  39.     {
  40.         return $this->projet;
  41.     }
  42.     public function setProjet(?Project $projet): self
  43.     {
  44.         $this->projet = $projet;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection|EngagementVersion[]
  49.      */
  50.     public function getEngagementVersion(): Collection
  51.     {
  52.         return $this->engagementVersion;
  53.     }
  54.     public function addEngagementVersion(EngagementVersion $engagementVersion): self
  55.     {
  56.         if (!$this->engagementVersion->contains($engagementVersion)) {
  57.             $this->engagementVersion[] = $engagementVersion;
  58.             $engagementVersion->setEngagementProjet($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeEngagementVersion(EngagementVersion $engagementVersion): self
  63.     {
  64.         if ($this->engagementVersion->removeElement($engagementVersion)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($engagementVersion->getEngagementProjet() === $this) {
  67.                 $engagementVersion->setEngagementProjet(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72. }