src/Entity/Project.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectRepository;
  4. use DateTimeImmutable;
  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(repositoryClassProjectRepository::class)]
  10. class Project
  11. {
  12.     public const TO_PROCESS 1;
  13.     public const FINISHED 2;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\Column(typeTypes::TEXT)]
  21.     private ?string $description null;
  22.     #[ORM\Column]
  23.     private ?int $progress 0;
  24.     #[ORM\Column]
  25.     private ?int $status self::TO_PROCESS;
  26.     #[ORM\Column]
  27.     private ?DateTimeImmutable $added_at null;
  28.     #[ORM\Column(nullabletrue)]
  29.     private ?DateTimeImmutable $updated_at null;
  30.     #[ORM\Column]
  31.     private ?int $is_active 1;
  32.     #[ORM\OneToMany(mappedBy'project'targetEntityTask::class, orphanRemovaltrue)]
  33.     private Collection $task;
  34.     #[ORM\ManyToOne(inversedBy'projects')]
  35.     private ?User $user null;
  36.     #[ORM\OneToOne(mappedBy'project'cascade: ['persist''remove'])]
  37.     private ?Step $step null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?\DateTimeImmutable $endAt null;
  40.     #[ORM\OneToMany(mappedBy'project'targetEntityRessource::class, orphanRemovaltrue)]
  41.     private Collection $ressource;
  42.     #[ORM\OneToMany(mappedBy'project'targetEntityRessourceDirectory::class, orphanRemovaltrue)]
  43.     #[ORM\OrderBy(['id' => 'DESC'])]
  44.     private Collection $ressourceDirectories;
  45.     public function __toString(): string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function __construct()
  50.     {
  51.         $this->setAddedAt(new DateTimeImmutable());
  52.         $this->task = new ArrayCollection();
  53.         $this->ressource = new ArrayCollection();
  54.         $this->ressourceDirectories = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(string $name): self
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(string $description): self
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function getProgress(): ?int
  79.     {
  80.         return $this->progress;
  81.     }
  82.     public function setProgress(int $progress): self
  83.     {
  84.         $this->progress $progress;
  85.         return $this;
  86.     }
  87.     public function getStatus(): ?int
  88.     {
  89.         return $this->status;
  90.     }
  91.     public function setStatus(int $status): self
  92.     {
  93.         $this->status $status;
  94.         return $this;
  95.     }
  96.     public function getAddedAt(): ?DateTimeImmutable
  97.     {
  98.         return $this->added_at;
  99.     }
  100.     public function setAddedAt(DateTimeImmutable $added_at): self
  101.     {
  102.         $this->added_at $added_at;
  103.         return $this;
  104.     }
  105.     public function getUpdatedAt(): ?DateTimeImmutable
  106.     {
  107.         return $this->updated_at;
  108.     }
  109.     public function setUpdatedAt(?DateTimeImmutable $updated_at): self
  110.     {
  111.         $this->updated_at $updated_at;
  112.         return $this;
  113.     }
  114.     public function getIsActive(): ?int
  115.     {
  116.         return $this->is_active;
  117.     }
  118.     public function setIsActive(?int $is_active): self
  119.     {
  120.         $this->is_active $is_active;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection<int, Task>
  125.      */
  126.     public function getTasks(): Collection
  127.     {
  128.         return $this->task;
  129.     }
  130.     public function addTask(Task $task): self
  131.     {
  132.         if (!$this->task->contains($task)) {
  133.             $this->task->add($task);
  134.             $task->setProject($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeTask(Task $task): self
  139.     {
  140.         if ($this->task->removeElement($task)) {
  141.             // set the owning side to null (unless already changed)
  142.             if ($task->getProject() === $this) {
  143.                 $task->setProject(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148.     public function getUser(): ?User
  149.     {
  150.         return $this->user;
  151.     }
  152.     public function setUser(?User $user): self
  153.     {
  154.         $this->user $user;
  155.         return $this;
  156.     }
  157.     public function getStep(): ?Step
  158.     {
  159.         return $this->step;
  160.     }
  161.     public function setStep(?Step $step): self
  162.     {
  163.         // unset the owning side of the relation if necessary
  164.         if ($step === null && $this->step !== null) {
  165.             $this->step->setProject(null);
  166.         }
  167.         // set the owning side of the relation if necessary
  168.         if ($step !== null && $step->getProject() !== $this) {
  169.             $step->setProject($this);
  170.         }
  171.         $this->step $step;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return Collection<int, Ressource>
  176.      */
  177.     public function getRessources(): Collection
  178.     {
  179.         return $this->ressource;
  180.     }
  181.     public function addRessource(Ressource $ressource): self
  182.     {
  183.         if (!$this->ressource->contains($ressource)) {
  184.             $this->ressource->add($ressource);
  185.             $ressource->setProject($this);
  186.         }
  187.         return $this;
  188.     }
  189.     public function removeRessource(Ressource $ressource): self
  190.     {
  191.         if ($this->ressource->removeElement($ressource)) {
  192.             // set the owning side to null (unless already changed)
  193.             if ($ressource->getProject() === $this) {
  194.                 $ressource->setProject(null);
  195.             }
  196.         }
  197.         return $this;
  198.     }
  199.     public function getEndAt(): ?\DateTimeImmutable
  200.     {
  201.         return $this->endAt;
  202.     }
  203.     public function setEndAt(?\DateTimeImmutable $endAt): self
  204.     {
  205.         $this->endAt $endAt;
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return Collection<int, Ressource>
  210.      */
  211.     public function getRessource(): Collection
  212.     {
  213.         return $this->ressource;
  214.     }
  215.     /**
  216.      * @return Collection<int, RessourceDirectory>
  217.      */
  218.     public function getRessourceDirectories(): Collection
  219.     {
  220.         return $this->ressourceDirectories;
  221.     }
  222.     public function addRessourceDirectory(RessourceDirectory $ressourceDirectory): self
  223.     {
  224.         if (!$this->ressourceDirectories->contains($ressourceDirectory)) {
  225.             $this->ressourceDirectories->add($ressourceDirectory);
  226.             $ressourceDirectory->setProject($this);
  227.         }
  228.         return $this;
  229.     }
  230.     public function removeRessourceDirectory(RessourceDirectory $ressourceDirectory): self
  231.     {
  232.         if ($this->ressourceDirectories->removeElement($ressourceDirectory)) {
  233.             // set the owning side to null (unless already changed)
  234.             if ($ressourceDirectory->getProject() === $this) {
  235.                 $ressourceDirectory->setProject(null);
  236.             }
  237.         }
  238.         return $this;
  239.     }
  240. }