<?php
namespace App\Entity\Account;
use App\Entity\App\App;
use App\Entity\Sync\SyncableInterface;
use App\Repository\Account\NotificationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
use Nellapp\Bundle\SDKBundle\Notification\Entity\NotificationInterface;
use Nellapp\Bundle\SDKBundle\Notification\Entity\NotificationMethodTrait;
use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
use Symfony\Component\Serializer\Annotation as Serial;
#[ORM\Entity(repositoryClass: NotificationRepository::class), ORM\Table(name: 'account_notifications')]
class Notification implements NotificationInterface, SyncableInterface
{
use TimestampTrait;
use NotificationMethodTrait;
#[
ORM\Id, ORM\GeneratedValue(strategy: 'NONE'),
ORM\Column(type: 'string', length: 36)
]
#[Serial\Groups(['Sync'])]
private ?string $id = null;
#[ORM\Column(type: 'string')]
#[Serial\Groups(['Sync'])]
protected ?string $label = null;
#[ORM\Column(type: 'string')]
#[Serial\Groups(['Sync'])]
protected ?string $type = null;
#[ORM\Column(type: 'string')]
#[Serial\Groups(['Sync'])]
protected ?string $status = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Serial\Groups(['Sync'])]
protected ?string $details = null;
#[ORM\ManyToOne(targetEntity: UserInterface::class)]
#[ORM\JoinColumn(onDelete: "CASCADE")]
#[IdGroups(groups: ['Sync'])]
protected UserInterface $user;
#[ORM\Column(type: Types::JSON, nullable: true)]
#[Serial\Groups(['Sync'])]
protected ?array $payload = [];
#[ORM\ManyToOne(targetEntity: App::class)]
#[ORM\JoinColumn(nullable: true, onDelete: "CASCADE")]
protected ?App $app = null;
public function getApp(): ?App
{
return $this->app;
}
public function setApp(?App $app): static
{
$this->app = $app;
return $this;
}
public static function getSyncKey(): string
{
return EntityKeys::USER_NOTIFICATION;
}
public function getSyncDisplayLabel(): string
{
return $this->getLabel() ?? 'notification';
}
}