vendor/roothirsch/tuer24-bundle/src/Entity/Tuer24NotificationPreference.php line 11

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\Tuer24Bundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Roothirsch\Tuer24Bundle\Repository\Tuer24NotificationPreferenceRepository;
  5. #[ORM\Entity(repositoryClass: Tuer24NotificationPreferenceRepository::class)]
  6. #[ORM\Table(name: 'roothirsch_tuer24_notification_preference')]
  7. #[ORM\HasLifecycleCallbacks]
  8. class Tuer24NotificationPreference
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column]
  13. private ?int $id = null;
  14. #[ORM\Column]
  15. private ?int $userId = null;
  16. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  17. private bool $orderCreated = true;
  18. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  19. private bool $orderStatusChanged = true;
  20. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  21. private bool $paymentConfirmed = true;
  22. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  23. private bool $paymentFailed = true;
  24. #[ORM\Column(type: 'datetime')]
  25. private ?\DateTime $createdAt = null;
  26. #[ORM\Column(type: 'datetime')]
  27. private ?\DateTime $updatedAt = null;
  28. public function __construct()
  29. {
  30. $this->createdAt = new \DateTime();
  31. $this->updatedAt = new \DateTime();
  32. }
  33. #[ORM\PreUpdate]
  34. public function preUpdate(): void
  35. {
  36. $this->updatedAt = new \DateTime();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getUserId(): ?int
  43. {
  44. return $this->userId;
  45. }
  46. public function setUserId(?int $userId): self
  47. {
  48. $this->userId = $userId;
  49. return $this;
  50. }
  51. public function isOrderCreated(): bool
  52. {
  53. return $this->orderCreated;
  54. }
  55. public function setOrderCreated(bool $orderCreated): self
  56. {
  57. $this->orderCreated = $orderCreated;
  58. return $this;
  59. }
  60. public function isOrderStatusChanged(): bool
  61. {
  62. return $this->orderStatusChanged;
  63. }
  64. public function setOrderStatusChanged(bool $orderStatusChanged): self
  65. {
  66. $this->orderStatusChanged = $orderStatusChanged;
  67. return $this;
  68. }
  69. public function isPaymentConfirmed(): bool
  70. {
  71. return $this->paymentConfirmed;
  72. }
  73. public function setPaymentConfirmed(bool $paymentConfirmed): self
  74. {
  75. $this->paymentConfirmed = $paymentConfirmed;
  76. return $this;
  77. }
  78. public function isPaymentFailed(): bool
  79. {
  80. return $this->paymentFailed;
  81. }
  82. public function setPaymentFailed(bool $paymentFailed): self
  83. {
  84. $this->paymentFailed = $paymentFailed;
  85. return $this;
  86. }
  87. public function getCreatedAt(): ?\DateTime
  88. {
  89. return $this->createdAt;
  90. }
  91. public function setCreatedAt(\DateTime $createdAt): self
  92. {
  93. $this->createdAt = $createdAt;
  94. return $this;
  95. }
  96. public function getUpdatedAt(): ?\DateTime
  97. {
  98. return $this->updatedAt;
  99. }
  100. public function setUpdatedAt(\DateTime $updatedAt): self
  101. {
  102. $this->updatedAt = $updatedAt;
  103. return $this;
  104. }
  105. /**
  106. * Check if a specific notification type is enabled
  107. */
  108. public function isNotificationEnabled(string $type): bool
  109. {
  110. switch ($type) {
  111. case 'order_created':
  112. return $this->orderCreated;
  113. case 'order_status_changed':
  114. return $this->orderStatusChanged;
  115. case 'payment_confirmed':
  116. return $this->paymentConfirmed;
  117. case 'payment_failed':
  118. return $this->paymentFailed;
  119. default:
  120. return true;
  121. }
  122. }
  123. }