src/Entity/Mission.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimeStampable;
  4. use App\Repository\MissionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClass: MissionRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class Mission
  12. {
  13.     use TimeStampable;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id = null;
  18.     #[ORM\Column(type: 'datetime_immutable', nullable: true)]
  19.     private ?\DateTimeImmutable $startDate = null;
  20.     #[ORM\Column(type: 'datetime_immutable', nullable: true)]
  21.     private ?\DateTimeImmutable $endDate = null;
  22.     #[ORM\Column]
  23.     private ?bool $isInternal = true;
  24.     #[ORM\ManyToOne]
  25.     private ?User $createdBy = null;
  26.     #[ORM\Column(length: 255, nullable: true)]
  27.     private ?string $subject = null;
  28.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  29.     private ?string $purpose = null;
  30.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  31.     private ?string $observation = null;
  32.     #[ORM\Column(length: 65, nullable: true)]
  33.     private ?string $reportFilename = null;
  34.     #[ORM\Column(length: 65, nullable: true)]
  35.     private ?string $letterFilename = null;
  36.     #[ORM\OneToMany(mappedBy: 'mission', targetEntity: MissionMember::class)]
  37.     private Collection $members;
  38.     #[ORM\OneToMany(mappedBy: 'mission', targetEntity: MissionStep::class)]
  39.     private Collection $missionSteps;
  40.     public function __construct()
  41.     {
  42.         $this->createdAt = new \DateTimeImmutable();
  43.         $this->updatedAt = new \DateTimeImmutable();
  44.         $this->members = new ArrayCollection();
  45.         $this->missionSteps = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getSubject(): ?string
  52.     {
  53.         return $this->subject;
  54.     }
  55.     public function setSubject(string $subject): self
  56.     {
  57.         $this->subject = $subject;
  58.         return $this;
  59.     }
  60.     public function getStartDate(): ?\DateTimeInterface
  61.     {
  62.         return $this->startDate;
  63.     }
  64.     public function setStartDate(\DateTimeInterface $startDate): self
  65.     {
  66.         $this->startDate = $startDate;
  67.         return $this;
  68.     }
  69.     public function getEndDate(): ?\DateTimeInterface
  70.     {
  71.         return $this->endDate;
  72.     }
  73.     public function setEndDate(\DateTimeInterface $endDate): self
  74.     {
  75.         $this->endDate = $endDate;
  76.         return $this;
  77.     }
  78.     public function isIsInternal(): ?bool
  79.     {
  80.         return $this->isInternal;
  81.     }
  82.     public function setIsInternal(bool $isInternal): self
  83.     {
  84.         $this->isInternal = $isInternal;
  85.         return $this;
  86.     }
  87.     public function getCreatedBy(): ?User
  88.     {
  89.         return $this->createdBy;
  90.     }
  91.     public function setCreatedBy(?User $createdBy): self
  92.     {
  93.         $this->createdBy = $createdBy;
  94.         return $this;
  95.     }
  96.     public function getPurpose(): ?string
  97.     {
  98.         return $this->purpose;
  99.     }
  100.     public function setPurpose(?string $purpose): self
  101.     {
  102.         $this->purpose = $purpose;
  103.         return $this;
  104.     }
  105.     public function getObservation(): ?string
  106.     {
  107.         return $this->observation;
  108.     }
  109.     public function setObservation(?string $observation): self
  110.     {
  111.         $this->observation = $observation;
  112.         return $this;
  113.     }
  114.     public function getReportFilename(): ?string
  115.     {
  116.         return $this->reportFilename;
  117.     }
  118.     public function setReportFilename(?string $reportFilename): self
  119.     {
  120.         $this->reportFilename = $reportFilename;
  121.         return $this;
  122.     }
  123.     public function getLetterFilename(): ?string
  124.     {
  125.         return $this->letterFilename;
  126.     }
  127.     public function setLetterFilename(?string $letterFilename): self
  128.     {
  129.         $this->letterFilename = $letterFilename;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, MissionMember>
  134.      */
  135.     public function getMembers(): Collection
  136.     {
  137.         return $this->members;
  138.     }
  139.     public function addMember(MissionMember $member): self
  140.     {
  141.         if (!$this->members->contains($member)) {
  142.             $this->members->add($member);
  143.             $member->setMission($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeMember(MissionMember $member): self
  148.     {
  149.         if ($this->members->removeElement($member)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($member->getMission() === $this) {
  152.                 $member->setMission(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, MissionStep>
  159.      */
  160.     public function getMissionSteps(): Collection
  161.     {
  162.         return $this->missionSteps;
  163.     }
  164.     public function addMissionStep(MissionStep $missionStep): self
  165.     {
  166.         if (!$this->missionSteps->contains($missionStep)) {
  167.             $this->missionSteps->add($missionStep);
  168.             $missionStep->setMission($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removeMissionStep(MissionStep $missionStep): self
  173.     {
  174.         if ($this->missionSteps->removeElement($missionStep)) {
  175.             // set the owning side to null (unless already changed)
  176.             if ($missionStep->getMission() === $this) {
  177.                 $missionStep->setMission(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182.     public function getMembersIds()
  183.     {
  184.         $idsList = [];
  185.         foreach($this->members as $member) {
  186.             $idsList[] = $member->getMember()->getId();
  187.         }
  188.         return $idsList;
  189.     }
  190. }