src/Entity/NewsletterSubscription.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NewsletterSubscriptionRepository;
  4. use BitBag\SyliusCmsPlugin\Entity\ChannelsAwareTrait;
  5. use DateTimeInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Sylius\Component\Channel\Model\ChannelAwareInterface;
  9. use Sylius\Component\Channel\Model\ChannelInterface;
  10. use Sylius\Component\Resource\Model\ResourceInterface;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. /**
  13.  * @ORM\Entity(repositoryClass=NewsletterSubscriptionRepository::class)
  14.  * @UniqueEntity(fields={"email", "channel"}, message="sylius.form.newsletter_subscription.email_already_subscribed", groups={"default"})
  15.  */
  16. class NewsletterSubscription implements ResourceInterfaceChannelAwareInterface
  17. {
  18.     use ChannelsAwareTrait;
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, unique=true)
  27.      */
  28.     private ?string $email;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity="App\Entity\Channel\Channel")
  31.      */
  32.     private ?ChannelInterface $channel;
  33.     /**
  34.      * @var DateTimeInterface|null
  35.      * @ORM\Column(type="datetime", nullable=true)
  36.      * @Gedmo\Timestampable(on="create")
  37.      */
  38.     private ?DateTimeInterface $createdAt;
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getEmail(): ?string
  44.     {
  45.         return $this->email;
  46.     }
  47.     public function setEmail(string $email): self
  48.     {
  49.         $this->email $email;
  50.         return $this;
  51.     }
  52.     public function getCreatedAt(): ?DateTimeInterface
  53.     {
  54.         return $this->createdAt;
  55.     }
  56.     public function getChannel(): ?ChannelInterface
  57.     {
  58.         return $this->channel;
  59.     }
  60.     public function setChannel(?ChannelInterface $channel): void
  61.     {
  62.         $this->channel $channel;
  63.     }
  64. }