src/Entity/Declaration/Definition.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Declaration;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7. * @ORM\Entity
  8. * @ORM\Table(name="brunex_declaration_definition")
  9. * @ApiResource(
  10. * routePrefix="/brunex/declaration",
  11. * normalizationContext={"groups"={"definition"}},
  12. * )
  13. */
  14. class Definition
  15. {
  16. /**
  17. * @var int
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. * @Groups({"product", "declaration"})
  22. */
  23. protected $id;
  24. /**
  25. * @var string
  26. * @ORM\Column(type="text")
  27. * @Groups({"product", "definition", "declaration"})
  28. */
  29. protected $defaultValue = '';
  30. /**
  31. * @var boolean
  32. * @ORM\Column(type="integer")
  33. * @Groups({"product", "definition", "declaration"})
  34. */
  35. protected $active = true;
  36. /**
  37. * @var array
  38. * @ORM\Column(type="array", nullable=true)
  39. * @Groups({"product", "definition", "declaration"})
  40. */
  41. protected $valueList = [];
  42. /**
  43. * @var Product
  44. * @ORM\ManyToOne(targetEntity="Product", inversedBy="definitions")
  45. * @ORM\JoinColumn(onDelete="CASCADE")
  46. */
  47. protected $product;
  48. /**
  49. * @var Field
  50. * @ORM\ManyToOne(targetEntity="Field")
  51. * @ORM\JoinColumn(onDelete="SET NULL")
  52. * @ORM\JoinColumn(onDelete="CASCADE")
  53. * @Groups({"product", "definition"})
  54. */
  55. protected $field;
  56. public function __toString()
  57. {
  58. return 'Definition ' . $this->product . ':' . $this->field;
  59. }
  60. /**
  61. * @return int
  62. */
  63. public function getId()
  64. {
  65. return $this->id;
  66. }
  67. /**
  68. * @return string
  69. */
  70. public function getDefaultValue()
  71. {
  72. return $this->defaultValue;
  73. }
  74. /**
  75. * @param string $defaultValue
  76. *
  77. * @return Definition
  78. */
  79. public function setDefaultValue($defaultValue)
  80. {
  81. $this->defaultValue = $defaultValue;
  82. return $this;
  83. }
  84. /**
  85. * @return array
  86. */
  87. public function getValueList()
  88. {
  89. return $this->valueList;
  90. }
  91. /**
  92. * @param array $valueList
  93. *
  94. * @return Definition
  95. */
  96. public function setValueList(array $valueList)
  97. {
  98. $this->valueList = $valueList;
  99. return $this;
  100. }
  101. /**
  102. * @return Product
  103. */
  104. public function getProduct()
  105. {
  106. return $this->product;
  107. }
  108. /**
  109. * @param Product $product
  110. *
  111. * @return Definition
  112. */
  113. public function setProduct($product)
  114. {
  115. $this->product = $product;
  116. return $this;
  117. }
  118. /**
  119. * @return Field
  120. */
  121. public function getField()
  122. {
  123. return $this->field;
  124. }
  125. /**
  126. * @param Field $field
  127. *
  128. * @return Definition
  129. */
  130. public function setField($field)
  131. {
  132. $this->field = $field;
  133. return $this;
  134. }
  135. /**
  136. * @return bool
  137. */
  138. public function isActive(): bool
  139. {
  140. return $this->active;
  141. }
  142. /**
  143. * @param bool $active
  144. */
  145. public function setActive(bool $active): void
  146. {
  147. $this->active = $active;
  148. }
  149. }