src/App/Entity/UserAdditionalInfo.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Exception;
  5. /**
  6. * @ORM\Entity
  7. *
  8. * @ORM\Table(
  9. * name="user_additional_infos",
  10. * indexes={
  11. *
  12. * @ORM\Index(name="info_name_info_string_value_idx", columns={"info_name", "info_string_value"}),
  13. * @ORM\Index(name="info_name_info_int_value_idx", columns={"info_name", "info_int_value"})
  14. * }
  15. * )
  16. */
  17. class UserAdditionalInfo
  18. {
  19. public const USER_ADDITIONAL_INFO_COMMENT = 'User Comment';
  20. public const USER_ADDITIONAL_INFO_ACTIVATION_DATE = 'Activation Date';
  21. /**
  22. * @var User
  23. *
  24. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="userAdditionalInfos", cascade={"persist"})
  25. *
  26. * @ORM\Id
  27. *
  28. * @ORM\JoinColumn(name="users_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  29. */
  30. private $user;
  31. public function getUser(): User
  32. {
  33. return $this->user;
  34. }
  35. public function setUser(User $user)
  36. {
  37. $this->user = $user;
  38. }
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Id
  43. *
  44. * @ORM\Column(type="string", nullable=false)
  45. */
  46. private $infoName;
  47. public function getInfoName(): string
  48. {
  49. return $this->infoName;
  50. }
  51. public function setInfoName(string $infoName): void
  52. {
  53. $this->infoName = $infoName;
  54. }
  55. /**
  56. * @var string
  57. *
  58. * @ORM\Column(type="string", nullable=true, length=3000)
  59. */
  60. private $infoStringValue;
  61. public function getInfoStringValue(): ?string
  62. {
  63. return $this->infoStringValue;
  64. }
  65. /** @throws Exception */
  66. public function setInfoStringValue(string $infoStringValue): void
  67. {
  68. if (!is_null($this->infoIntValue)) {
  69. throw new Exception('Cannot set infoStringValue because infoIntValue is already set.');
  70. }
  71. $this->infoStringValue = $infoStringValue;
  72. }
  73. /**
  74. * @var int
  75. *
  76. * @ORM\Column(type="integer", nullable=true)
  77. */
  78. private $infoIntValue;
  79. public function getInfoIntValue(): ?int
  80. {
  81. return $this->infoIntValue;
  82. }
  83. /** @throws Exception */
  84. public function setInfoIntValue(int $infoIntValue): void
  85. {
  86. if (!is_null($this->infoStringValue)) {
  87. throw new Exception('Cannot set infoIntValue because infoStringValue is already set.');
  88. }
  89. $this->infoIntValue = $infoIntValue;
  90. }
  91. }