Нет описания

StatisticsUnsubscribeEntity.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace MailPoet\Entities;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
  5. use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
  6. use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
  7. use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity()
  10. * @ORM\Table(name="statistics_unsubscribes")
  11. */
  12. class StatisticsUnsubscribeEntity {
  13. use AutoincrementedIdTrait;
  14. use CreatedAtTrait;
  15. use SafeToOneAssociationLoadTrait;
  16. const SOURCE_NEWSLETTER = 'newsletter';
  17. const SOURCE_MANAGE = 'manage';
  18. const SOURCE_ADMINISTRATOR = 'admin';
  19. const SOURCE_ORDER_CHECKOUT = 'order_checkout';
  20. /**
  21. * @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
  22. * @ORM\JoinColumn(name="newsletter_id", referencedColumnName="id")
  23. * @var NewsletterEntity|null
  24. */
  25. private $newsletter;
  26. /**
  27. * @ORM\ManyToOne(targetEntity="MailPoet\Entities\SendingQueueEntity")
  28. * @ORM\JoinColumn(name="queue_id", referencedColumnName="id")
  29. * @var SendingQueueEntity|null
  30. */
  31. private $queue;
  32. /**
  33. * @ORM\ManyToOne(targetEntity="MailPoet\Entities\SubscriberEntity")
  34. * @ORM\JoinColumn(name="subscriber_id", referencedColumnName="id")
  35. * @var SubscriberEntity|null
  36. */
  37. private $subscriber;
  38. /**
  39. * @ORM\Column(type="string")
  40. * @var string
  41. */
  42. private $source = 'unknown';
  43. /**
  44. * @ORM\Column(type="string", nullable=true)
  45. * @var string|null
  46. */
  47. private $meta;
  48. public function __construct(
  49. NewsletterEntity $newsletter = null,
  50. SendingQueueEntity $queue = null,
  51. SubscriberEntity $subscriber
  52. ) {
  53. $this->newsletter = $newsletter;
  54. $this->queue = $queue;
  55. $this->subscriber = $subscriber;
  56. }
  57. /**
  58. * @return NewsletterEntity|null
  59. */
  60. public function getNewsletter() {
  61. $this->safelyLoadToOneAssociation('newsletter');
  62. return $this->newsletter;
  63. }
  64. /**
  65. * @return SendingQueueEntity|null
  66. */
  67. public function getQueue() {
  68. $this->safelyLoadToOneAssociation('queue');
  69. return $this->queue;
  70. }
  71. /**
  72. * @return string
  73. */
  74. public function getSource(): string {
  75. return $this->source;
  76. }
  77. /**
  78. * @param string $source
  79. */
  80. public function setSource(string $source) {
  81. $this->source = $source;
  82. }
  83. /**
  84. * @param string $meta
  85. */
  86. public function setMeta(string $meta) {
  87. $this->meta = $meta;
  88. }
  89. /**
  90. * @return string|null
  91. */
  92. public function getMeta() {
  93. return $this->meta;
  94. }
  95. }