src/Entity/SubjectTag.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubjectTagRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9. * @ORM\Entity(repositoryClass=SubjectTagRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class SubjectTag extends BaseEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. * @Serializer\Expose
  19. * @Serializer\Groups({"ligth_list"})
  20. */
  21. private $id;
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. * @Serializer\Expose
  25. * @Serializer\Groups({"ligth_list"})
  26. */
  27. private $name;
  28. /**
  29. * @ORM\ManyToMany(targetEntity=Subject::class, inversedBy="subjectTags")
  30. */
  31. private $subjects;
  32. public function __construct()
  33. {
  34. $this->subjects = new ArrayCollection();
  35. }
  36. public function getId(): ?int
  37. {
  38. return $this->id;
  39. }
  40. public function getName(): ?string
  41. {
  42. return $this->name;
  43. }
  44. public function setName(string $name): self
  45. {
  46. $this->name = $name;
  47. return $this;
  48. }
  49. /**
  50. * @return Collection<int, Subject>
  51. */
  52. public function getSubjects(): Collection
  53. {
  54. return $this->subjects;
  55. }
  56. public function addSubject(Subject $subject): self
  57. {
  58. if (!$this->subjects->contains($subject)) {
  59. $this->subjects[] = $subject;
  60. }
  61. return $this;
  62. }
  63. public function removeSubject(Subject $subject): self
  64. {
  65. $this->subjects->removeElement($subject);
  66. return $this;
  67. }
  68. }