src/Entity/Label.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LabelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\Timestampable;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=LabelRepository::class)
  11.  */
  12. class Label
  13. {
  14.     use TimestampableEntity;
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="text", nullable=true)
  27.      */
  28.     private $description;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Label::class, inversedBy="children")
  31.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id" )
  32.      */
  33.     private $parent;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Machine::class, mappedBy="parent")
  36.      */
  37.     private $children;
  38.     /**
  39.      * @ORM\Column(type="integer")
  40.      */
  41.      private $labelOrder;
  42.      /**
  43.       * @ORM\OneToMany(targetEntity=Task::class, mappedBy="label")
  44.       */
  45.      private $tasks;
  46.     public function __construct()
  47.     {
  48.         $this->children = new ArrayCollection();
  49.         $this->tasks = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getDescription(): ?string
  65.     {
  66.         return $this->description;
  67.     }
  68.     public function setDescription(?string $description): self
  69.     {
  70.         $this->description $description;
  71.         return $this;
  72.     }
  73.     public function getParent(): ?self
  74.     {
  75.         return $this->parent;
  76.     }
  77.     public function setParent(?self $parentId): self
  78.     {
  79.         $this->parent $parentId;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, self>
  84.      */
  85.     public function getChildren(): Collection
  86.     {
  87.         return $this->children;
  88.     }
  89.     public function addChild(self $child): self
  90.     {
  91.         if (!$this->children->contains($child)) {
  92.             $this->children[] = $child;
  93.             $child->setParent($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeChild(self $child): self
  98.     {
  99.         if ($this->children->removeElement($child)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($child->getParent() === $this) {
  102.                 $child->setParent(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     public function getLabelOrder(): ?int
  108.     {
  109.         return $this->labelOrder;
  110.     }
  111.     public function setLabelOrder(int $labelOrder): self
  112.     {
  113.         $this->labelOrder $labelOrder;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, Task>
  118.      */
  119.     public function getTasks(): Collection
  120.     {
  121.         return $this->tasks;
  122.     }
  123.     public function addTask(Task $task): self
  124.     {
  125.         if (!$this->tasks->contains($task)) {
  126.             $this->tasks[] = $task;
  127.             $task->setLabel($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeTask(Task $task): self
  132.     {
  133.         if ($this->tasks->removeElement($task)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($task->getLabel() === $this) {
  136.                 $task->setLabel(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141. }