vendor/crea/parameter-bundle/src/Entity/ParameterType.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Crea\ParameterBundle\Entity;
  4. use Crea\ParameterBundle\Annotation\CreateParameterTypeFixtureValidator;
  5. use Crea\ParameterBundle\Annotation\CreateParameterTypeFormValidator;
  6. use Crea\ParameterBundle\Annotation\UpdateParameterTypeFixtureValidator;
  7. use Crea\ParameterBundle\Annotation\UpdateParameterTypeFormValidator;
  8. use Crea\ParameterBundle\Repository\ParameterTypeRepository;
  9. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. /**
  14. * @ORM\Entity(repositoryClass=ParameterTypeRepository::class)
  15. *
  16. * @CreateParameterTypeFixtureValidator(groups={"create_parameter_type_fixture_validator"})
  17. * @UpdateParameterTypeFixtureValidator(groups={"update_parameter_type_fixture_validator"})
  18. * @CreateParameterTypeFormValidator(groups={"create_parameter_type_form_validator"})
  19. * @UpdateParameterTypeFormValidator(groups={"update_parameter_type_form_validator"})
  20. *
  21. * @ORM\Table(name="parameter_type")
  22. */
  23. class ParameterType
  24. {
  25. use LifecycleUserIdentifierTrait;
  26. /**
  27. * @ORM\Id()
  28. *
  29. * @ORM\GeneratedValue()
  30. *
  31. * @ORM\Column(type="integer")
  32. */
  33. protected int $id;
  34. /**
  35. * @ORM\ManyToOne(targetEntity=ParameterGroup::class, inversedBy="parameterTypes")
  36. *
  37. * @ORM\JoinColumn(nullable=false)
  38. */
  39. protected ParameterGroup $parameterGroup;
  40. /**
  41. * @ORM\Column(type="string", length=255, nullable=false)
  42. */
  43. protected string $label;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=false)
  46. */
  47. protected string $code;
  48. /**
  49. * @ORM\Column(type="text", nullable=true)
  50. */
  51. protected ?string $description = null;
  52. /**
  53. * @var Collection<int, ParameterTypeAttribute>
  54. *
  55. * @ORM\OneToMany(targetEntity=ParameterTypeAttribute::class, mappedBy="parameterType", orphanRemoval=true, cascade={"all"})
  56. */
  57. protected Collection $parameterTypeAttributes;
  58. /**
  59. * @var Collection<int, Parameter>
  60. *
  61. * @ORM\OneToMany(targetEntity=Parameter::class, mappedBy="parameterType", orphanRemoval=true, cascade={"all"})
  62. *
  63. * @ORM\OrderBy({"displayIndex" = "ASC"})
  64. */
  65. protected Collection $parameters;
  66. public function __construct()
  67. {
  68. $this->parameterTypeAttributes = new ArrayCollection();
  69. $this->parameters = new ArrayCollection();
  70. }
  71. public function getId(): int
  72. {
  73. return $this->id;
  74. }
  75. public function setId(int $id): self
  76. {
  77. $this->id = $id;
  78. return $this;
  79. }
  80. public function getParameterGroup(): ParameterGroup
  81. {
  82. return $this->parameterGroup;
  83. }
  84. public function setParameterGroup(ParameterGroup $parameterGroup): self
  85. {
  86. $this->parameterGroup = $parameterGroup;
  87. return $this;
  88. }
  89. public function getLabel(): string
  90. {
  91. return $this->label;
  92. }
  93. public function setLabel(string $label): self
  94. {
  95. $this->label = $label;
  96. return $this;
  97. }
  98. public function getCode(): string
  99. {
  100. return $this->code;
  101. }
  102. public function setCode(string $code): self
  103. {
  104. $this->code = $code;
  105. return $this;
  106. }
  107. public function getDescription(): ?string
  108. {
  109. return $this->description;
  110. }
  111. public function setDescription(?string $description): self
  112. {
  113. $this->description = $description;
  114. return $this;
  115. }
  116. /**
  117. * @return Collection<int, ParameterTypeAttribute>
  118. */
  119. public function getParameterTypeAttributes(): Collection
  120. {
  121. return $this->parameterTypeAttributes;
  122. }
  123. /**
  124. * @param Collection<int, ParameterTypeAttribute> $parameterTypeAttributes
  125. */
  126. public function setParameterTypeAttributes(Collection $parameterTypeAttributes): self
  127. {
  128. $this->parameterTypeAttributes = $parameterTypeAttributes;
  129. return $this;
  130. }
  131. public function addParameterTypeAttribute(ParameterTypeAttribute $parameterTypeAttribute): self
  132. {
  133. if (!$this->parameterTypeAttributes->contains($parameterTypeAttribute)) {
  134. $this->parameterTypeAttributes[] = $parameterTypeAttribute;
  135. $parameterTypeAttribute->setParameterType($this);
  136. }
  137. return $this;
  138. }
  139. public function removeParameterTypeAttribute(ParameterTypeAttribute $parameterTypeAttribute): self
  140. {
  141. if ($this->parameterTypeAttributes->removeElement($parameterTypeAttribute)) {
  142. if ($parameterTypeAttribute->getParameterType() === $this) {
  143. $parameterTypeAttribute->setParameterType(null);
  144. }
  145. }
  146. return $this;
  147. }
  148. /**
  149. * @return Collection<int, Parameter>
  150. */
  151. public function getParameters(): Collection
  152. {
  153. return $this->parameters;
  154. }
  155. /**
  156. * @param Collection<int, Parameter> $parameters
  157. */
  158. public function setParameters(Collection $parameters): self
  159. {
  160. $this->parameters = $parameters;
  161. return $this;
  162. }
  163. public function addParameter(Parameter $parameter): self
  164. {
  165. if (!$this->parameters->contains($parameter)) {
  166. $this->parameters[] = $parameter;
  167. $parameter->setParameterType($this);
  168. }
  169. return $this;
  170. }
  171. public function removeParameter(Parameter $parameter): self
  172. {
  173. $this->parameters->removeElement($parameter);
  174. return $this;
  175. }
  176. }