src/Entity/Account/Notification.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Account;
  3. use App\Entity\App\App;
  4. use App\Entity\Sync\SyncableInterface;
  5. use App\Repository\Account\NotificationRepository;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  9. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
  10. use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
  11. use Nellapp\Bundle\SDKBundle\Notification\Entity\NotificationInterface;
  12. use Nellapp\Bundle\SDKBundle\Notification\Entity\NotificationMethodTrait;
  13. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  14. use Symfony\Component\Serializer\Annotation as Serial;
  15. #[ORM\Entity(repositoryClass: NotificationRepository::class), ORM\Table(name: 'account_notifications')]
  16. class Notification implements NotificationInterface, SyncableInterface
  17. {
  18. use TimestampTrait;
  19. use NotificationMethodTrait;
  20. #[
  21. ORM\Id, ORM\GeneratedValue(strategy: 'NONE'),
  22. ORM\Column(type: 'string', length: 36)
  23. ]
  24. #[Serial\Groups(['Sync'])]
  25. private ?string $id = null;
  26. #[ORM\Column(type: 'string')]
  27. #[Serial\Groups(['Sync'])]
  28. protected ?string $label = null;
  29. #[ORM\Column(type: 'string')]
  30. #[Serial\Groups(['Sync'])]
  31. protected ?string $type = null;
  32. #[ORM\Column(type: 'string')]
  33. #[Serial\Groups(['Sync'])]
  34. protected ?string $status = null;
  35. #[ORM\Column(type: 'text', nullable: true)]
  36. #[Serial\Groups(['Sync'])]
  37. protected ?string $details = null;
  38. #[ORM\ManyToOne(targetEntity: UserInterface::class)]
  39. #[ORM\JoinColumn(onDelete: "CASCADE")]
  40. #[IdGroups(groups: ['Sync'])]
  41. protected UserInterface $user;
  42. #[ORM\Column(type: Types::JSON, nullable: true)]
  43. #[Serial\Groups(['Sync'])]
  44. protected ?array $payload = [];
  45. #[ORM\ManyToOne(targetEntity: App::class)]
  46. #[ORM\JoinColumn(nullable: true, onDelete: "CASCADE")]
  47. protected ?App $app = null;
  48. public function getApp(): ?App
  49. {
  50. return $this->app;
  51. }
  52. public function setApp(?App $app): static
  53. {
  54. $this->app = $app;
  55. return $this;
  56. }
  57. public static function getSyncKey(): string
  58. {
  59. return EntityKeys::USER_NOTIFICATION;
  60. }
  61. public function getSyncDisplayLabel(): string
  62. {
  63. return $this->getLabel() ?? 'notification';
  64. }
  65. }