src/Entity/Application/DeviceToken.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Application;
  3. use App\Entity\Client;
  4. use App\Repository\Application\DeviceTokenRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=DeviceTokenRepository::class)
  10. */
  11. class DeviceToken
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private ?int $id;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. */
  22. private $token;
  23. /**
  24. * @ORM\Column(type="string", length=2)
  25. */
  26. private $locale = 'cs';
  27. /**
  28. * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="deviceTokens")
  29. */
  30. private $client;
  31. /**
  32. * @ORM\Column(type="datetime")
  33. */
  34. private $createts;
  35. /**
  36. * @ORM\OneToMany(targetEntity=NotificationSeen::class, mappedBy="token", orphanRemoval=true)
  37. */
  38. private $notificationSeens;
  39. public function __construct()
  40. {
  41. if ($this->getCreatets() === null) {
  42. $this->setCreatets(new \DateTime());
  43. }
  44. $this->notificationSeens = new ArrayCollection();
  45. }
  46. public function setId(?int $id): void
  47. {
  48. $this->id = $id;
  49. }
  50. public function getId(): ?int
  51. {
  52. return $this->id;
  53. }
  54. public function getToken(): ?string
  55. {
  56. return $this->token;
  57. }
  58. public function setToken(string $token): self
  59. {
  60. $this->token = $token;
  61. return $this;
  62. }
  63. public function getClient(): ?Client
  64. {
  65. return $this->client;
  66. }
  67. public function setClient(?Client $client): self
  68. {
  69. $this->client = $client;
  70. return $this;
  71. }
  72. public function getCreatets(): ?\DateTimeInterface
  73. {
  74. return $this->createts;
  75. }
  76. public function setCreatets(\DateTimeInterface $createts): self
  77. {
  78. $this->createts = $createts;
  79. return $this;
  80. }
  81. /**
  82. * @return mixed
  83. */
  84. public function getLocale(): string
  85. {
  86. return $this->locale;
  87. }
  88. /**
  89. * @param mixed $locale
  90. */
  91. public function setLocale(string $locale): void
  92. {
  93. $this->locale = $locale;
  94. }
  95. /**
  96. * @return Collection|NotificationSeen[]
  97. */
  98. public function getNotificationSeens(): Collection
  99. {
  100. return $this->notificationSeens;
  101. }
  102. public function addNotificationSeen(NotificationSeen $notificationSeen): self
  103. {
  104. if (!$this->notificationSeens->contains($notificationSeen)) {
  105. $this->notificationSeens[] = $notificationSeen;
  106. $notificationSeen->setToken($this);
  107. }
  108. return $this;
  109. }
  110. public function removeNotificationSeen(NotificationSeen $notificationSeen): self
  111. {
  112. if ($this->notificationSeens->removeElement($notificationSeen)) {
  113. // set the owning side to null (unless already changed)
  114. if ($notificationSeen->getToken() === $this) {
  115. $notificationSeen->setToken(null);
  116. }
  117. }
  118. return $this;
  119. }
  120. }