src\Entity\UserSubscription.php line 11

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