src/Entity/UserExtension.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Annotation\Exportable;
  4. use App\Annotation\ExportableEntity;
  5. use App\Repository\UserExtensionRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use DateTime;
  10. /**
  11. * @ORM\Entity(repositoryClass=UserExtensionRepository::class)
  12. *
  13. * @ORM\HasLifecycleCallbacks
  14. * @ExportableEntity
  15. */
  16. class UserExtension
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. */
  23. private ?int $id = NULL;
  24. /**
  25. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="extensions")
  26. * @ORM\JoinColumn(nullable=false)
  27. *
  28. * @Assert\NotNull
  29. */
  30. private ?User $user = NULL;
  31. /**
  32. * @ORM\Column(type="string", length=64)
  33. *
  34. * @Assert\NotBlank
  35. * @Assert\Length(
  36. * min = 3,
  37. * max = 64,
  38. * )
  39. *
  40. * @Exportable("slug")
  41. */
  42. private ?string $slug = NULL;
  43. /**
  44. * @ORM\Column(type="text")
  45. *
  46. * @Assert\NotBlank
  47. *
  48. * @Exportable("value")
  49. */
  50. private ?string $value = NULL;
  51. /**
  52. * @Gedmo\Timestampable(on="create")
  53. * @ORM\Column(type="datetime", nullable=true)
  54. */
  55. private ?DateTime $createdAt = NULL;
  56. public function getSerialized(): string
  57. {
  58. return $this->getSlug() . ':' . $this->getValue();
  59. }
  60. public function getId(): ?int
  61. {
  62. return $this->id;
  63. }
  64. public function getUser(): ?User
  65. {
  66. return $this->user;
  67. }
  68. public function setUser(?User $user): self
  69. {
  70. $this->user = $user;
  71. return $this;
  72. }
  73. public function getSlug(): ?string
  74. {
  75. return $this->slug;
  76. }
  77. public function setSlug(string $slug): self
  78. {
  79. $this->slug = $slug;
  80. return $this;
  81. }
  82. public function getValue(): ?string
  83. {
  84. return $this->value;
  85. }
  86. public function setValue(string $value): self
  87. {
  88. $this->value = $value;
  89. return $this;
  90. }
  91. public function getCreatedAt(): ?DateTime
  92. {
  93. return $this->createdAt;
  94. }
  95. public function setCreatedAt( ?DateTime $createdAt ): self
  96. {
  97. $this->createdAt = $createdAt;
  98. return $this;
  99. }
  100. }