<?php
namespace App\Entity;
use App\Repository\NewsletterSubscriptionRepository;
use BitBag\SyliusCmsPlugin\Entity\ChannelsAwareTrait;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Sylius\Component\Channel\Model\ChannelAwareInterface;
use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=NewsletterSubscriptionRepository::class)
* @UniqueEntity(fields={"email", "channel"}, message="sylius.form.newsletter_subscription.email_already_subscribed", groups={"default"})
*/
class NewsletterSubscription implements ResourceInterface, ChannelAwareInterface
{
use ChannelsAwareTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private ?string $email;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Channel\Channel")
*/
private ?ChannelInterface $channel;
/**
* @var DateTimeInterface|null
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="create")
*/
private ?DateTimeInterface $createdAt;
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function getChannel(): ?ChannelInterface
{
return $this->channel;
}
public function setChannel(?ChannelInterface $channel): void
{
$this->channel = $channel;
}
}