src/Entity/SemanticTag.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SemanticTagRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassSemanticTagRepository::class)]
  9. class SemanticTag
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\ManyToOne(targetEntityProject::class, inversedBy'semanticTags')]
  16.     #[ORM\JoinColumn(onDelete'CASCADE')]
  17.     private $project;
  18.     #[ORM\ManyToOne(targetEntityWorkroom::class, inversedBy'semanticTags')]
  19.     #[ORM\JoinColumn(onDelete'CASCADE')]
  20.     private $workroom;
  21.     #[ORM\Column(type'string'length255)]
  22.     private $name;
  23.     #[ORM\Column(type'string'length255uniquetrue)]
  24.     #[Assert\NotBlank]
  25.     private $code;
  26.     #[ORM\ManyToMany(targetEntityReadingCard::class, mappedBy'semanticTag')]
  27.     private $readingCards;
  28.     #[ORM\Column(type'string'nullablefalse)]
  29.     private $color;
  30.     /** T2 — parent_id pour hiérarchie de tags (Méthodologie > Quantitative > Statistiques). */
  31.     #[ORM\ManyToOne(targetEntitySemanticTag::class)]
  32.     #[ORM\JoinColumn(name'parent_id'referencedColumnName'id'nullabletrueonDelete'SET NULL')]
  33.     private ?SemanticTag $parent null;
  34.     public function __construct()
  35.     {
  36.         $this->readingCards = new ArrayCollection();
  37.     }
  38.     public function getParent(): ?SemanticTag { return $this->parent; }
  39.     public function setParent(?SemanticTag $parent): self $this->parent $parent; return $this; }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getCode(): ?string
  54.     {
  55.         return $this->code;
  56.     }
  57.     public function setCode(string $code): self
  58.     {
  59.         $this->code $code;
  60.         return $this;
  61.     }
  62.     /**
  63.      * @return Collection|ReadingCard[]
  64.      */
  65.     public function getReadingCards(): Collection
  66.     {
  67.         return $this->readingCards;
  68.     }
  69.     public function addReadingCard(ReadingCard $readingCard): self
  70.     {
  71.         if (!$this->readingCards->contains($readingCard)) {
  72.             $this->readingCards[] = $readingCard;
  73.             $readingCard->addSemanticTag($this);
  74.         }
  75.         return $this;
  76.     }
  77.     public function removeReadingCard(ReadingCard $readingCard): self
  78.     {
  79.         if ($this->readingCards->removeElement($readingCard)) {
  80.             $readingCard->removeSemanticTag($this);
  81.         }
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return string
  86.      */
  87.     public function getColor(): string
  88.     {
  89.         return $this->color;
  90.     }
  91.     /**
  92.      * @param string $color
  93.      * @return $this
  94.      */
  95.     public function setColor(string $color): self
  96.     {
  97.         $this->color $color;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Project|null
  102.      */
  103.     public function getProject(): ?Project
  104.     {
  105.         return $this->project;
  106.     }
  107.     /**
  108.      * @param Project|null $project
  109.      * @return $this
  110.      */
  111.     public function setProject(?Project $project): self
  112.     {
  113.         $this->project $project;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Workroom|null
  118.      */
  119.     public function getWorkroom(): ?Workroom
  120.     {
  121.         return $this->workroom;
  122.     }
  123.     /**
  124.      * @param Workroom|null $workroom
  125.      * @return $this
  126.      */
  127.     public function setWorkroom(?Workroom $workroom): self
  128.     {
  129.         $this->workroom $workroom;
  130.         return $this;
  131.     }
  132. }