src/Entity/PSG.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PSGRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass: PSGRepository::class)]
  9. class PSG
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id = null;
  15.     #[ORM\Column]
  16.     private ?bool $isValided = null;
  17.     #[ORM\Column(type: Types::DATETIME_MUTABLE)]
  18.     private ?\DateTimeInterface $dateStart = null;
  19.     #[ORM\Column(type: Types::DATETIME_MUTABLE)]
  20.     private ?\DateTimeInterface $dateEnd = null;
  21.     #[ORM\OneToOne(mappedBy: 'psg', cascade: ['persist', 'remove'])]
  22.     private ?Analyse $analyse = null;
  23.     #[ORM\OneToMany(mappedBy: 'Psg', targetEntity: Enjeux::class)]
  24.     private Collection $enjeuxes;
  25.     #[ORM\Column]
  26.     private ?int $status = null;
  27.     public function __construct()
  28.     {
  29.         $this->enjeuxes = new ArrayCollection();
  30.         $this->isValided = false;
  31.         $this->status = 0;
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function setIsValided(bool $isValided): static
  38.     {
  39.         $this->isValided = $isValided;
  40.         return $this;
  41.     }
  42.     public function getIsValided(): bool {
  43.         return $this->isValided;
  44.     }
  45.     public function getDateStart(): ?\DateTimeInterface
  46.     {
  47.         return $this->dateStart;
  48.     }
  49.     public function setDateStart(\DateTimeInterface $dateStart): static
  50.     {
  51.         $this->dateStart = $dateStart;
  52.         return $this;
  53.     }
  54.     public function getDateEnd(): ?\DateTimeInterface
  55.     {
  56.         return $this->dateEnd;
  57.     }
  58.     public function setDateEnd(\DateTimeInterface $dateEnd): static
  59.     {
  60.         $this->dateEnd = $dateEnd;
  61.         return $this;
  62.     }
  63.     public function getAnalyse(): ?Analyse
  64.     {
  65.         return $this->analyse;
  66.     }
  67.     public function setAnalyse(?Analyse $analyse): static
  68.     {
  69.         // unset the owning side of the relation if necessary
  70.         if ($analyse === null && $this->analyse !== null) {
  71.             $this->analyse->setPsg(null);
  72.         }
  73.         // set the owning side of the relation if necessary
  74.         if ($analyse !== null && $analyse->getPsg() !== $this) {
  75.             $analyse->setPsg($this);
  76.         }
  77.         $this->analyse = $analyse;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, Enjeux>
  82.      */
  83.     public function getEnjeuxes(): Collection
  84.     {
  85.         return $this->enjeuxes;
  86.     }
  87.     public function addEnjeux(Enjeux $enjeux): static
  88.     {
  89.         if (!$this->enjeuxes->contains($enjeux)) {
  90.             $this->enjeuxes->add($enjeux);
  91.             $enjeux->setPsg($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeEnjeux(Enjeux $enjeux): static
  96.     {
  97.         if ($this->enjeuxes->removeElement($enjeux)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($enjeux->getPsg() === $this) {
  100.                 $enjeux->setPsg(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function getStatus(): ?int
  106.     {
  107.         return $this->status;
  108.     }
  109.     public function setStatus(int $status): static
  110.     {
  111.         $this->status = $status;
  112.         return $this;
  113.     }
  114.     public function displayStatus(): string {
  115.         return $this->status == 0 ? 'Brouillon': 'Encore cours';
  116.     }
  117.     public function orientations(): array {
  118.         $orientations = [];
  119.     
  120.         foreach ($this->getEnjeuxes() as $enjeux) {
  121.             foreach ($enjeux->getOrientation() as $orientation) {
  122.                 $orientations[] = $orientation; 
  123.             }
  124.         }
  125.     
  126.         return $orientations;
  127.     }
  128.     
  129. }