Нет описания

SendingQueueEntity.php 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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\DeletedAtTrait;
  7. use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
  8. use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
  9. use MailPoet\Util\Helpers;
  10. use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
  11. use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13. * @ORM\Entity()
  14. * @ORM\Table(name="sending_queues")
  15. */
  16. class SendingQueueEntity {
  17. const STATUS_COMPLETED = 'completed';
  18. const STATUS_SCHEDULED = 'scheduled';
  19. const STATUS_PAUSED = 'paused';
  20. const PRIORITY_HIGH = 1;
  21. const PRIORITY_MEDIUM = 5;
  22. const PRIORITY_LOW = 10;
  23. use AutoincrementedIdTrait;
  24. use CreatedAtTrait;
  25. use UpdatedAtTrait;
  26. use DeletedAtTrait;
  27. use SafeToOneAssociationLoadTrait;
  28. /**
  29. * @ORM\Column(type="json_or_serialized")
  30. * @Assert\Type("array")
  31. * @Assert\Collection(
  32. * fields = {
  33. * "html" = @Assert\NotBlank(),
  34. * "text" = @Assert\NotBlank(),
  35. * }
  36. * )
  37. * @var array|null
  38. */
  39. private $newsletterRenderedBody;
  40. /**
  41. * @ORM\Column(type="string", nullable=true)
  42. * @var string|null
  43. */
  44. private $newsletterRenderedSubject;
  45. /**
  46. * @ORM\Column(type="text", nullable=true)
  47. * @var string|null
  48. */
  49. private $subscribers;
  50. /**
  51. * @ORM\Column(type="integer")
  52. * @var int
  53. */
  54. private $countTotal = 0;
  55. /**
  56. * @ORM\Column(type="integer")
  57. * @var int
  58. */
  59. private $countProcessed = 0;
  60. /**
  61. * @ORM\Column(type="integer")
  62. * @var int
  63. */
  64. private $countToProcess = 0;
  65. /**
  66. * @ORM\Column(type="json", nullable=true)
  67. * @var array|null
  68. */
  69. private $meta;
  70. /**
  71. * @ORM\OneToOne(targetEntity="MailPoet\Entities\ScheduledTaskEntity", fetch="EAGER")
  72. * @var ScheduledTaskEntity|null
  73. */
  74. private $task;
  75. /**
  76. * @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity", inversedBy="queues")
  77. * @var NewsletterEntity|null
  78. */
  79. private $newsletter;
  80. /**
  81. * @deprecated This is here only for backward compatibility with custom shortcodes https://kb.mailpoet.com/article/160-create-a-custom-shortcode
  82. * This can be removed after 2021-08-01
  83. */
  84. public function __get($key) {
  85. $getterName = 'get' . Helpers::underscoreToCamelCase($key, $capitaliseFirstChar = true);
  86. $callable = [$this, $getterName];
  87. if (is_callable($callable)) {
  88. return call_user_func($callable);
  89. }
  90. }
  91. /**
  92. * @return array|null
  93. */
  94. public function getNewsletterRenderedBody() {
  95. return $this->newsletterRenderedBody;
  96. }
  97. /**
  98. * @param array|null $newsletterRenderedBody
  99. */
  100. public function setNewsletterRenderedBody($newsletterRenderedBody) {
  101. $this->newsletterRenderedBody = $newsletterRenderedBody;
  102. }
  103. /**
  104. * @return string|null
  105. */
  106. public function getNewsletterRenderedSubject() {
  107. return $this->newsletterRenderedSubject;
  108. }
  109. /**
  110. * @param string|null $newsletterRenderedSubject
  111. */
  112. public function setNewsletterRenderedSubject($newsletterRenderedSubject) {
  113. $this->newsletterRenderedSubject = $newsletterRenderedSubject;
  114. }
  115. /**
  116. * @return string|null
  117. */
  118. public function getSubscribers() {
  119. return $this->subscribers;
  120. }
  121. /**
  122. * @param string|null $subscribers
  123. */
  124. public function setSubscribers($subscribers) {
  125. $this->subscribers = $subscribers;
  126. }
  127. /**
  128. * @return int
  129. */
  130. public function getCountTotal() {
  131. return $this->countTotal;
  132. }
  133. /**
  134. * @param int $countTotal
  135. */
  136. public function setCountTotal($countTotal) {
  137. $this->countTotal = $countTotal;
  138. }
  139. /**
  140. * @return int
  141. */
  142. public function getCountProcessed() {
  143. return $this->countProcessed;
  144. }
  145. /**
  146. * @param int $countProcessed
  147. */
  148. public function setCountProcessed($countProcessed) {
  149. $this->countProcessed = $countProcessed;
  150. }
  151. /**
  152. * @return int
  153. */
  154. public function getCountToProcess() {
  155. return $this->countToProcess;
  156. }
  157. /**
  158. * @param int $countToProcess
  159. */
  160. public function setCountToProcess($countToProcess) {
  161. $this->countToProcess = $countToProcess;
  162. }
  163. /**
  164. * @return array|null
  165. */
  166. public function getMeta() {
  167. return $this->meta;
  168. }
  169. /**
  170. * @param array|null $meta
  171. */
  172. public function setMeta($meta) {
  173. $this->meta = $meta;
  174. }
  175. /**
  176. * @return ScheduledTaskEntity|null
  177. */
  178. public function getTask() {
  179. $this->safelyLoadToOneAssociation('task');
  180. return $this->task;
  181. }
  182. public function setTask(ScheduledTaskEntity $task) {
  183. $this->task = $task;
  184. }
  185. /**
  186. * @return NewsletterEntity|null
  187. */
  188. public function getNewsletter() {
  189. $this->safelyLoadToOneAssociation('newsletter');
  190. return $this->newsletter;
  191. }
  192. public function setNewsletter(NewsletterEntity $newsletter) {
  193. $this->newsletter = $newsletter;
  194. }
  195. }