src/Entity/UserExtension.php line 16

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 Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9. * @ORM\Entity(repositoryClass=UserExtensionRepository::class)
  10. *
  11. * @ExportableEntity
  12. */
  13. class UserExtension
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. */
  20. private ?int $id = NULL;
  21. /**
  22. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="extensions")
  23. * @ORM\JoinColumn(nullable=false)
  24. *
  25. * @Assert\NotNull
  26. */
  27. private ?User $user = NULL;
  28. /**
  29. * @ORM\Column(type="string", length=64)
  30. *
  31. * @Assert\NotBlank
  32. * @Assert\Length(
  33. * min = 3,
  34. * max = 64,
  35. * )
  36. *
  37. * @Exportable("slug")
  38. */
  39. private ?string $slug = NULL;
  40. /**
  41. * @ORM\Column(type="text")
  42. *
  43. * @Assert\NotBlank
  44. *
  45. * @Exportable("value")
  46. */
  47. private ?string $value = NULL;
  48. public function getSerialized(): string
  49. {
  50. return $this->getSlug() . ':' . $this->getValue();
  51. }
  52. public function getId(): ?int
  53. {
  54. return $this->id;
  55. }
  56. public function getUser(): ?User
  57. {
  58. return $this->user;
  59. }
  60. public function setUser(?User $user): self
  61. {
  62. $this->user = $user;
  63. return $this;
  64. }
  65. public function getSlug(): ?string
  66. {
  67. return $this->slug;
  68. }
  69. public function setSlug(string $slug): self
  70. {
  71. $this->slug = $slug;
  72. return $this;
  73. }
  74. public function getValue(): ?string
  75. {
  76. return $this->value;
  77. }
  78. public function setValue(string $value): self
  79. {
  80. $this->value = $value;
  81. return $this;
  82. }
  83. }