src/Entity/AccountDeletionLog.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Repository\AccountDeletionLogRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * Trace d'une suppression de compte (RGPD), sans aucune donnée personnelle.
  9.  *
  10.  * Volontairement sans clé étrangère vers user : la trace doit survivre à tout
  11.  * nettoyage du compte. subjectHash = HMAC-SHA256 de l'id utilisateur avec APP_SECRET,
  12.  * pour pouvoir répondre « ce compte a-t-il été supprimé ? » sans stocker l'id en clair.
  13.  *
  14.  * @ORM\Entity(repositoryClass=AccountDeletionLogRepository::class)
  15.  * @ORM\Table(name="account_deletion_log", indexes={
  16.  *     @ORM\Index(name="idx_account_deletion_log_subject", columns={"subject_hash"})
  17.  * })
  18.  */
  19. class AccountDeletionLog
  20. {
  21.     public const CHANNEL_WEB = 'web';
  22.     public const CHANNEL_APP = 'app';
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private ?int $id = null;
  29.     /**
  30.      * HMAC-SHA256 (hex) de l'id utilisateur
  31.      *
  32.      * @ORM\Column(type="string", length=64)
  33.      */
  34.     private string $subjectHash;
  35.     /**
  36.      * Catégorie du compte supprimé (client…)
  37.      *
  38.      * @ORM\Column(type="string", length=50)
  39.      */
  40.     private string $category;
  41.     /**
  42.      * Canal de la demande : web ou app
  43.      *
  44.      * @ORM\Column(type="string", length=10)
  45.      */
  46.     private string $channel;
  47.     /**
  48.      * Nombre de lignes supprimées ou anonymisées par table (jamais de valeur)
  49.      *
  50.      * @ORM\Column(type="json")
  51.      */
  52.     private array $summary = [];
  53.     /**
  54.      * Date de la suppression
  55.      *
  56.      * @ORM\Column(type="datetime_immutable")
  57.      * @Gedmo\Timestampable(on="create")
  58.      */
  59.     private ?\DateTimeImmutable $createdAt = null;
  60.     /**
  61.      * @ORM\Column(type="datetime_immutable")
  62.      * @Gedmo\Timestampable
  63.      */
  64.     private ?\DateTimeImmutable $updatedAt = null;
  65.     public function __construct(string $subjectHash, string $category, string $channel)
  66.     {
  67.         $this->subjectHash = $subjectHash;
  68.         $this->category = $category;
  69.         $this->channel = $channel;
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getSubjectHash(): string
  76.     {
  77.         return $this->subjectHash;
  78.     }
  79.     public function getCategory(): string
  80.     {
  81.         return $this->category;
  82.     }
  83.     public function getChannel(): string
  84.     {
  85.         return $this->channel;
  86.     }
  87.     public function getSummary(): array
  88.     {
  89.         return $this->summary;
  90.     }
  91.     public function setSummary(array $summary): self
  92.     {
  93.         $this->summary = $summary;
  94.         return $this;
  95.     }
  96.     public function getCreatedAt(): ?\DateTimeImmutable
  97.     {
  98.         return $this->createdAt;
  99.     }
  100.     public function getUpdatedAt(): ?\DateTimeImmutable
  101.     {
  102.         return $this->updatedAt;
  103.     }
  104. }