src/Entity/TypeStructure.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * TypeStructure.
  9. *
  10. * @ORM\Table(name="TypeStructure")
  11. *
  12. * @ORM\Entity
  13. */
  14. class TypeStructure
  15. {
  16. /**
  17. * @var int
  18. *
  19. * @ORM\Column(name="id", type="integer")
  20. *
  21. * @ORM\Id
  22. *
  23. * @ORM\GeneratedValue(strategy="AUTO")
  24. */
  25. private $id;
  26. /**
  27. * @var string
  28. *
  29. * @ORM\Column(name="nom", type="string", length=255)
  30. */
  31. private $nom;
  32. /**
  33. * @ORM\OneToMany(targetEntity="Structure", mappedBy="typeStructure")
  34. */
  35. private $structures;
  36. /**
  37. * @ORM\ManyToMany(targetEntity=FiltreStructure::class, mappedBy="typesStructure")
  38. */
  39. private $filtreStructures;
  40. /**
  41. * Constructor.
  42. */
  43. public function __construct()
  44. {
  45. $this->structures = new ArrayCollection();
  46. $this->filtreStructures = new ArrayCollection();
  47. }
  48. /**
  49. * Methode pour afficher le type.
  50. */
  51. #[\Override]
  52. public function __toString(): string
  53. {
  54. return (string) $this->getNom() ?? '';
  55. }
  56. /**
  57. * Get id.
  58. *
  59. * @return int
  60. */
  61. public function getId()
  62. {
  63. return $this->id;
  64. }
  65. /**
  66. * Set nom.
  67. *
  68. * @param string $nom
  69. */
  70. public function setNom($nom): static
  71. {
  72. $this->nom = $nom;
  73. return $this;
  74. }
  75. /**
  76. * Get nom.
  77. *
  78. * @return string
  79. */
  80. public function getNom()
  81. {
  82. return $this->nom;
  83. }
  84. /**
  85. * Add structures.
  86. */
  87. public function addStructure(Structure $structures): static
  88. {
  89. $this->structures[] = $structures;
  90. return $this;
  91. }
  92. /**
  93. * Remove structures.
  94. */
  95. public function removeStructure(Structure $structures): void
  96. {
  97. $this->structures->removeElement($structures);
  98. }
  99. /**
  100. * Get structures.
  101. *
  102. * @return Collection
  103. */
  104. public function getStructures()
  105. {
  106. return $this->structures;
  107. }
  108. /**
  109. * @return Collection<int, FiltreStructure>
  110. */
  111. public function getFiltreStructures(): Collection
  112. {
  113. return $this->filtreStructures;
  114. }
  115. public function addFiltreStructure(FiltreStructure $filtreStructure): self
  116. {
  117. if (!$this->filtreStructures->contains($filtreStructure)) {
  118. $this->filtreStructures[] = $filtreStructure;
  119. $filtreStructure->addTypesStructure($this);
  120. }
  121. return $this;
  122. }
  123. public function removeFiltreStructure(FiltreStructure $filtreStructure): self
  124. {
  125. if ($this->filtreStructures->removeElement($filtreStructure)) {
  126. $filtreStructure->removeTypesStructure($this);
  127. }
  128. return $this;
  129. }
  130. }