src\Entity\UserSubscription.php line 9

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserSubscriptionRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity(repositoryClassUserSubscriptionRepository::class)]
  6. class UserSubscription
  7. {
  8.     #[ORM\Id]
  9.     #[ORM\GeneratedValue]
  10.     #[ORM\Column(type'integer')]
  11.     private $id;
  12.     #[ORM\Column(type'datetime')]
  13.     private $created_at;
  14.     public function __construct(#[ORM\Column(type'json')]
  15.     private array $subscription,#[ORM\Column(type'string'length255nullablefalse)]
  16.     private string $subscriptionHash, #[ORM\JoinColumn(nullabletrue)]
  17.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'userSubscriptions')]
  18.     private ?\App\Entity\User $user null)
  19.     {
  20.         $this->created_at = new \DateTime();
  21.     }
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getUser(): ?User
  27.     {
  28.         return $this->user;
  29.     }
  30.     public function setUser(?User $user): self
  31.     {
  32.         $this->user $user;
  33.         return $this;
  34.     }
  35.     public function getSubscriptionHash(): ?string
  36.     {
  37.         return $this->subscriptionHash;
  38.     }
  39.     public function setSubscriptionHash(string $subscriptionHash): self
  40.     {
  41.         $this->subscriptionHash $subscriptionHash;
  42.         return $this;
  43.     }
  44.     public function getSubscription(): ?array
  45.     {
  46.         return $this->subscription;
  47.     }
  48.     public function setSubscription(array $subscription): self
  49.     {
  50.         $this->subscription $subscription;
  51.         return $this;
  52.         //"publicKey": "BCK-VclcEiwr2Tx4Yaz__vjm-c44dacN0C1bPba3v76okSoc5cOHW7xtBP-MfV6E3VRxCa4z9qa8xVDauSbrQxw",
  53.         //  "privateKey": "Gb5bw-rUNBzlZk2HzWT0WWhKUNV8wrCsV-WzeGH6R5c"
  54.         //{"endpoint":"https://fcm.googleapis.com/fcm/send/cEF3b2beWUM:APA91bGfrKUFrArIhPyPt44nnOkpp910cDfl515Xlpr1H02qbD8RJbXeE-OpI4Oqcmvn38JSaATB3A5ktyn7zEwv7AuXF_z8TR0-3Nz_wXGvDLEZnfu8askdb_vgCDWXr3zOQzFaUgWB",
  55.         //"expirationTime":null,
  56.         //"keys":{"p256dh":"BDbEjEfSf1ONfmePXJWHUcwcQU150yTmH2Eubz7OwC85n2xvvQR4azgNdh0MPieEl7I14Q_YjHzXexZIg5q5EF8",
  57.         //          "auth":"_TBkovDYmMOjl7Ip70SLng"}}
  58.     }
  59.     /**
  60.      * debut du code modifié
  61.      */
  62.     /**
  63.      * @inheritDoc
  64.      */
  65.     public function getEndpoint(): string
  66.     {
  67.         return $this->subscription['endpoint'];
  68.     }
  69.     /**
  70.      * @inheritDoc
  71.      */
  72.     public function getPublicKey(): string
  73.     {
  74.         return $this->subscription['keys']['p256dh'];
  75.     }
  76.     /**
  77.      * @inheritDoc
  78.      */
  79.     public function getAuthToken(): string
  80.     {
  81.         return $this->subscription['keys']['auth'];
  82.     }
  83.     /**
  84.      * Content-encoding (default: aesgcm).
  85.      *
  86.      * @return string
  87.      */
  88.     public function getContentEncoding(): string
  89.     {
  90.         return $this->subscription['content-encoding'] ?? 'aesgcm';
  91.     }
  92.     public function getCreatedAt(): ?\DateTimeInterface
  93.     {
  94.         return $this->created_at;
  95.     }
  96.     public function setCreatedAt(\DateTimeInterface $created_at): self
  97.     {
  98.         $this->created_at $created_at;
  99.         return $this;
  100.     }
  101. }