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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Crea\ParameterBundle\Entity;
  4. use Crea\ParameterBundle\Annotation\CreateParameterFixtureValidator;
  5. use Crea\ParameterBundle\Annotation\CreateParameterFormValidator;
  6. use Crea\ParameterBundle\Annotation\UpdateParameterFixtureValidator;
  7. use Crea\ParameterBundle\Annotation\UpdateParameterFormValidator;
  8. use Crea\ParameterBundle\Repository\ParameterRepository;
  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=ParameterRepository::class)
  15. *
  16. * @CreateParameterFixtureValidator(groups={"create_parameter_fixture_validator"})
  17. * @UpdateParameterFixtureValidator(groups={"update_parameter_fixture_validator"})
  18. * @CreateParameterFormValidator(groups={"create_parameter_form_validator"})
  19. * @UpdateParameterFormValidator(groups={"update_parameter_form_validator"})
  20. *
  21. * @ORM\Table(name="parameter")
  22. */
  23. class Parameter
  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="ParameterType", inversedBy="parameters")
  36. *
  37. * @ORM\JoinColumn(nullable=false)
  38. */
  39. protected ParameterType $parameterType;
  40. /**
  41. * @ORM\Column(type="string", length=255, nullable=false)
  42. */
  43. protected ?string $label = null;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=false)
  46. */
  47. protected ?string $code = null;
  48. /**
  49. * @ORM\Column(type="string", nullable=true)
  50. */
  51. protected ?string $description = null;
  52. /**
  53. * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  54. */
  55. protected bool $defaultParameter = false;
  56. /**
  57. * @ORM\Column(type="integer", nullable=false, options={"default" : 1})
  58. */
  59. private int $displayIndex = 1;
  60. /**
  61. * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  62. */
  63. protected bool $active = true;
  64. /**
  65. * @var Collection<int, ParameterAttributeValue>
  66. *
  67. * @ORM\OneToMany(targetEntity=ParameterAttributeValue::class, mappedBy="parameter", orphanRemoval=true, cascade={"all"})
  68. */
  69. private Collection $parameterAttributeValues;
  70. public function __construct()
  71. {
  72. $this->parameterAttributeValues = new ArrayCollection();
  73. }
  74. public function getId(): int
  75. {
  76. return $this->id;
  77. }
  78. public function setId(int $id): self
  79. {
  80. $this->id = $id;
  81. return $this;
  82. }
  83. public function getParameterType(): ParameterType
  84. {
  85. return $this->parameterType;
  86. }
  87. public function setParameterType(ParameterType $parameterType): self
  88. {
  89. $this->parameterType = $parameterType;
  90. return $this;
  91. }
  92. public function getLabel(): ?string
  93. {
  94. return $this->label;
  95. }
  96. public function setLabel(?string $label): self
  97. {
  98. $this->label = $label;
  99. return $this;
  100. }
  101. public function getCode(): ?string
  102. {
  103. return $this->code;
  104. }
  105. public function setCode(?string $code): self
  106. {
  107. $this->code = $code;
  108. return $this;
  109. }
  110. public function getDescription(): ?string
  111. {
  112. return $this->description;
  113. }
  114. public function setDescription(?string $description): self
  115. {
  116. $this->description = $description;
  117. return $this;
  118. }
  119. public function isDefaultParameter(): bool
  120. {
  121. return $this->defaultParameter;
  122. }
  123. public function setDefaultParameter(bool $defaultParameter): self
  124. {
  125. $this->defaultParameter = $defaultParameter;
  126. return $this;
  127. }
  128. public function getDisplayIndex(): int
  129. {
  130. return $this->displayIndex;
  131. }
  132. public function setDisplayIndex(int $displayIndex): self
  133. {
  134. $this->displayIndex = $displayIndex;
  135. return $this;
  136. }
  137. public function isActive(): bool
  138. {
  139. return $this->active;
  140. }
  141. public function setActive(bool $active): self
  142. {
  143. $this->active = $active;
  144. return $this;
  145. }
  146. /**
  147. * @return Collection<int, ParameterAttributeValue>
  148. */
  149. public function getParameterAttributeValues(): Collection
  150. {
  151. return $this->parameterAttributeValues;
  152. }
  153. /**
  154. * @param Collection<int, ParameterAttributeValue> $parameterAttributeValues
  155. */
  156. public function setParameterAttributeValues(Collection $parameterAttributeValues): self
  157. {
  158. $this->parameterAttributeValues = $parameterAttributeValues;
  159. return $this;
  160. }
  161. public function addParameterAttributeValue(ParameterAttributeValue $parameterAttributeValue): self
  162. {
  163. if (!$this->parameterAttributeValues->contains($parameterAttributeValue)) {
  164. $this->parameterAttributeValues[] = $parameterAttributeValue;
  165. $parameterAttributeValue->setParameter($this);
  166. }
  167. return $this;
  168. }
  169. public function removeParameterAttributeValue(ParameterAttributeValue $parameterAttributeValue): self
  170. {
  171. if ($this->parameterAttributeValues->removeElement($parameterAttributeValue)) {
  172. if ($parameterAttributeValue->getParameter() === $this) {
  173. $parameterAttributeValue->setParameter(null);
  174. }
  175. }
  176. return $this;
  177. }
  178. }