src/Entity/AgendaReminder.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AgendaReminderRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassAgendaReminderRepository::class)]
  7. #[ORM\Table(
  8.     name'agenda_reminder',
  9.     uniqueConstraints: [
  10.         new ORM\UniqueConstraint(
  11.             name'UNIQ_AGENDA_REMINDER_SIGNATURE',
  12.             columns: ['user_id''source_type''source_id''remind_at''channel']
  13.         ),
  14.     ],
  15.     indexes: [
  16.         new ORM\Index(name'IDX_AGENDA_REMINDER_DUE'columns: ['status''remind_at']),
  17.         new ORM\Index(name'IDX_AGENDA_REMINDER_USER_STATUS'columns: ['user_id''status']),
  18.     ]
  19. )]
  20. class AgendaReminder
  21. {
  22.     public const STATUS_PENDING 'pending';
  23.     public const STATUS_SENT 'sent';
  24.     public const STATUS_CANCELED 'canceled';
  25.     public const SOURCE_INTEREST_ACTIVITY 'interest_activity';
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column]
  29.     private ?int $id null;
  30.     #[ORM\ManyToOne]
  31.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  32.     private ?User $user null;
  33.     #[ORM\Column(length40)]
  34.     private string $sourceType self::SOURCE_INTEREST_ACTIVITY;
  35.     #[ORM\Column]
  36.     private int $sourceId 0;
  37.     #[ORM\Column(length180)]
  38.     private string $title '';
  39.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  40.     private ?\DateTimeImmutable $scheduledAt null;
  41.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  42.     private ?\DateTimeImmutable $remindAt null;
  43.     #[ORM\Column(length64)]
  44.     private string $timezone 'Europe/Paris';
  45.     #[ORM\Column(length20)]
  46.     private string $channel 'in_app';
  47.     #[ORM\Column(length20)]
  48.     private string $status self::STATUS_PENDING;
  49.     #[ORM\Column(length255nullabletrue)]
  50.     private ?string $actionUrl null;
  51.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  52.     private \DateTimeImmutable $createdAt;
  53.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  54.     private \DateTimeImmutable $updatedAt;
  55.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  56.     private ?\DateTimeImmutable $sentAt null;
  57.     public function __construct()
  58.     {
  59.         $now = new \DateTimeImmutable();
  60.         $this->createdAt $now;
  61.         $this->updatedAt $now;
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getUser(): ?User
  68.     {
  69.         return $this->user;
  70.     }
  71.     public function setUser(?User $user): self
  72.     {
  73.         $this->user $user;
  74.         return $this;
  75.     }
  76.     public function getSourceType(): string
  77.     {
  78.         return $this->sourceType;
  79.     }
  80.     public function setSourceType(string $sourceType): self
  81.     {
  82.         $this->sourceType mb_substr(trim($sourceType), 040);
  83.         return $this;
  84.     }
  85.     public function getSourceId(): int
  86.     {
  87.         return $this->sourceId;
  88.     }
  89.     public function setSourceId(int $sourceId): self
  90.     {
  91.         $this->sourceId max(0$sourceId);
  92.         return $this;
  93.     }
  94.     public function getTitle(): string
  95.     {
  96.         return $this->title;
  97.     }
  98.     public function setTitle(string $title): self
  99.     {
  100.         $this->title mb_substr(trim($title), 0180);
  101.         return $this;
  102.     }
  103.     public function getScheduledAt(): ?\DateTimeImmutable
  104.     {
  105.         return $this->scheduledAt;
  106.     }
  107.     public function setScheduledAt(?\DateTimeImmutable $scheduledAt): self
  108.     {
  109.         $this->scheduledAt $scheduledAt;
  110.         return $this;
  111.     }
  112.     public function getRemindAt(): ?\DateTimeImmutable
  113.     {
  114.         return $this->remindAt;
  115.     }
  116.     public function setRemindAt(?\DateTimeImmutable $remindAt): self
  117.     {
  118.         $this->remindAt $remindAt;
  119.         return $this;
  120.     }
  121.     public function getTimezone(): string
  122.     {
  123.         return $this->timezone;
  124.     }
  125.     public function setTimezone(string $timezone): self
  126.     {
  127.         $this->timezone mb_substr(trim($timezone), 064);
  128.         return $this;
  129.     }
  130.     public function getChannel(): string
  131.     {
  132.         return $this->channel;
  133.     }
  134.     public function setChannel(string $channel): self
  135.     {
  136.         $this->channel mb_substr(trim($channel), 020);
  137.         return $this;
  138.     }
  139.     public function getStatus(): string
  140.     {
  141.         return $this->status;
  142.     }
  143.     public function setStatus(string $status): self
  144.     {
  145.         $this->status mb_substr(trim($status), 020);
  146.         $this->touch();
  147.         return $this;
  148.     }
  149.     public function getActionUrl(): ?string
  150.     {
  151.         return $this->actionUrl;
  152.     }
  153.     public function setActionUrl(?string $actionUrl): self
  154.     {
  155.         $value trim((string) ($actionUrl ?? ''));
  156.         $this->actionUrl $value === '' null mb_substr($value0255);
  157.         return $this;
  158.     }
  159.     public function getCreatedAt(): \DateTimeImmutable
  160.     {
  161.         return $this->createdAt;
  162.     }
  163.     public function getUpdatedAt(): \DateTimeImmutable
  164.     {
  165.         return $this->updatedAt;
  166.     }
  167.     public function touch(): self
  168.     {
  169.         $this->updatedAt = new \DateTimeImmutable();
  170.         return $this;
  171.     }
  172.     public function getSentAt(): ?\DateTimeImmutable
  173.     {
  174.         return $this->sentAt;
  175.     }
  176.     public function setSentAt(?\DateTimeImmutable $sentAt): self
  177.     {
  178.         $this->sentAt $sentAt;
  179.         $this->touch();
  180.         return $this;
  181.     }
  182. }