<?php
namespace App\Entity;
use App\Repository\UserSubscriptionRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: UserSubscriptionRepository::class)]
class UserSubscription
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'datetime')]
private $created_at;
public function __construct(#[ORM\Column(type: 'json')]
private array $subscription,#[ORM\Column(type: 'string', length: 255, nullable: false)]
private string $subscriptionHash, #[ORM\JoinColumn(nullable: true)]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'userSubscriptions')]
private ?\App\Entity\User $user = null)
{
$this->created_at = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getSubscriptionHash(): ?string
{
return $this->subscriptionHash;
}
public function setSubscriptionHash(string $subscriptionHash): self
{
$this->subscriptionHash = $subscriptionHash;
return $this;
}
public function getSubscription(): ?array
{
return $this->subscription;
}
public function setSubscription(array $subscription): self
{
$this->subscription = $subscription;
return $this;
//"publicKey": "BCK-VclcEiwr2Tx4Yaz__vjm-c44dacN0C1bPba3v76okSoc5cOHW7xtBP-MfV6E3VRxCa4z9qa8xVDauSbrQxw",
// "privateKey": "Gb5bw-rUNBzlZk2HzWT0WWhKUNV8wrCsV-WzeGH6R5c"
//{"endpoint":"https://fcm.googleapis.com/fcm/send/cEF3b2beWUM:APA91bGfrKUFrArIhPyPt44nnOkpp910cDfl515Xlpr1H02qbD8RJbXeE-OpI4Oqcmvn38JSaATB3A5ktyn7zEwv7AuXF_z8TR0-3Nz_wXGvDLEZnfu8askdb_vgCDWXr3zOQzFaUgWB",
//"expirationTime":null,
//"keys":{"p256dh":"BDbEjEfSf1ONfmePXJWHUcwcQU150yTmH2Eubz7OwC85n2xvvQR4azgNdh0MPieEl7I14Q_YjHzXexZIg5q5EF8",
// "auth":"_TBkovDYmMOjl7Ip70SLng"}}
}
/**
* debut du code modifié
*/
/**
* @inheritDoc
*/
public function getEndpoint(): string
{
return $this->subscription['endpoint'];
}
/**
* @inheritDoc
*/
public function getPublicKey(): string
{
return $this->subscription['keys']['p256dh'];
}
/**
* @inheritDoc
*/
public function getAuthToken(): string
{
return $this->subscription['keys']['auth'];
}
/**
* Content-encoding (default: aesgcm).
*
* @return string
*/
public function getContentEncoding(): string
{
return $this->subscription['content-encoding'] ?? 'aesgcm';
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
}