src/Entity/TaskStatus.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TaskStatusRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassTaskStatusRepository::class)]
  8. class TaskStatus
  9. {
  10.     use IdentifiableTrait;
  11.     #[ORM\Column(length30)]
  12.     private ?string $name null;
  13.     #[ORM\Column(length30)]
  14.     private ?string $slug null;
  15.     #[ORM\Column(nullabletrue)]
  16.     private ?int $position null;
  17.     #[ORM\OneToMany(mappedBy'status'targetEntityTask::class, orphanRemovaltrue)]
  18.     private Collection $tasks;
  19.     public function __construct()
  20.     {
  21.         $this->tasks = new ArrayCollection();
  22.     }
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getName(): ?string
  28.     {
  29.         return $this->name;
  30.     }
  31.     public function setName(string $name): static
  32.     {
  33.         $this->name $name;
  34.         return $this;
  35.     }
  36.     public function getSlug(): ?string
  37.     {
  38.         return $this->slug;
  39.     }
  40.     public function setSlug(string $slug): static
  41.     {
  42.         $this->slug $slug;
  43.         return $this;
  44.     }
  45.     public function getPosition(): ?int
  46.     {
  47.         return $this->position;
  48.     }
  49.     public function setPosition(?int $position): static
  50.     {
  51.         $this->position $position;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, Task>
  56.      */
  57.     public function getTasks(): Collection
  58.     {
  59.         return $this->tasks;
  60.     }
  61.     public function addTask(Task $task): static
  62.     {
  63.         if (!$this->tasks->contains($task)) {
  64.             $this->tasks->add($task);
  65.             $task->setStatus($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeTask(Task $task): static
  70.     {
  71.         if ($this->tasks->removeElement($task)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($task->getStatus() === $this) {
  74.                 $task->setStatus(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79. }