Add Doctrine entities for newsletters, options, and segments
[MAILPOET-2216]
This commit is contained in:
330
lib/Entities/NewsletterEntity.php
Normal file
330
lib/Entities/NewsletterEntity.php
Normal file
@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use DateTimeInterface;
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
||||
use MailPoetVendor\Doctrine\Common\Collections\Collection;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping\Column;
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Table(name="newsletters")
|
||||
*/
|
||||
class NewsletterEntity {
|
||||
// types
|
||||
const TYPE_AUTOMATIC = 'automatic';
|
||||
const TYPE_STANDARD = 'standard';
|
||||
const TYPE_WELCOME = 'welcome';
|
||||
const TYPE_NOTIFICATION = 'notification';
|
||||
const TYPE_NOTIFICATION_HISTORY = 'notification_history';
|
||||
|
||||
// standard newsletters
|
||||
const STATUS_DRAFT = 'draft';
|
||||
const STATUS_SCHEDULED = 'scheduled';
|
||||
const STATUS_SENDING = 'sending';
|
||||
const STATUS_SENT = 'sent';
|
||||
|
||||
// automatic newsletters status
|
||||
const STATUS_ACTIVE = 'active';
|
||||
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use DeletedAtTrait;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string|null
|
||||
*/
|
||||
private $hash;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $sender_address;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $sender_name;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $status = self::STATUS_DRAFT;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $reply_to_address;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $reply_to_name;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $preheader;
|
||||
|
||||
/**
|
||||
* @Column(type="json")
|
||||
* @var array|null
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* @Column(type="datetimetz")
|
||||
* @var DateTimeInterface|null
|
||||
*/
|
||||
private $sent_at;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string|null
|
||||
*/
|
||||
private $unsubscribe_token;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
* @var NewsletterEntity|null
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="MailPoet\Entities\NewsletterSegmentEntity", mappedBy="newsletter")
|
||||
* @var NewsletterSegmentEntity[]|Collection
|
||||
*/
|
||||
private $newsletter_segments;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="MailPoet\Entities\NewsletterOptionEntity", mappedBy="newsletter")
|
||||
* @var NewsletterOptionEntity[]|Collection
|
||||
*/
|
||||
private $options;
|
||||
|
||||
function __construct() {
|
||||
$this->newsletter_segments = new ArrayCollection();
|
||||
$this->options = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
function getHash() {
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $hash
|
||||
*/
|
||||
function setHash($hash) {
|
||||
$this->hash = $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getSubject() {
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
*/
|
||||
function setSubject($subject) {
|
||||
$this->subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getSenderAddress() {
|
||||
return $this->sender_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sender_address
|
||||
*/
|
||||
function setSenderAddress($sender_address) {
|
||||
$this->sender_address = $sender_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getSenderName() {
|
||||
return $this->sender_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sender_name
|
||||
*/
|
||||
function setSenderName($sender_name) {
|
||||
$this->sender_name = $sender_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
*/
|
||||
function setStatus($status) {
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getReplyToAddress() {
|
||||
return $this->reply_to_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $reply_to_address
|
||||
*/
|
||||
function setReplyToAddress($reply_to_address) {
|
||||
$this->reply_to_address = $reply_to_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getReplyToName() {
|
||||
return $this->reply_to_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $reply_to_name
|
||||
*/
|
||||
function setReplyToName($reply_to_name) {
|
||||
$this->reply_to_name = $reply_to_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getPreheader() {
|
||||
return $this->preheader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $preheader
|
||||
*/
|
||||
function setPreheader($preheader) {
|
||||
$this->preheader = $preheader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
function getBody() {
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $body
|
||||
*/
|
||||
function setBody($body) {
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface|null
|
||||
*/
|
||||
function getSentAt() {
|
||||
return $this->sent_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeInterface|null $sent_at
|
||||
*/
|
||||
function setSentAt($sent_at) {
|
||||
$this->sent_at = $sent_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
function getUnsubscribeToken() {
|
||||
return $this->unsubscribe_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $unsubscribe_token
|
||||
*/
|
||||
function setUnsubscribeToken($unsubscribe_token) {
|
||||
$this->unsubscribe_token = $unsubscribe_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NewsletterEntity|null
|
||||
*/
|
||||
function getParent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterEntity|null $parent
|
||||
*/
|
||||
function setParent($parent) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NewsletterSegmentEntity[]|Collection
|
||||
*/
|
||||
function getNewsletterSegments() {
|
||||
return $this->newsletter_segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NewsletterOptionEntity[]|Collection
|
||||
*/
|
||||
function getOptions() {
|
||||
return $this->options;
|
||||
}
|
||||
}
|
77
lib/Entities/NewsletterOptionEntity.php
Normal file
77
lib/Entities/NewsletterOptionEntity.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Table(name="newsletter_option")
|
||||
*/
|
||||
class NewsletterOptionEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Column(type="text")
|
||||
* @var string|null
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity", inversedBy="options")
|
||||
* @var NewsletterEntity
|
||||
*/
|
||||
private $newsletter;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="MailPoet\Entities\NewsletterOptionFieldEntity", inversedBy="options")
|
||||
* @var NewsletterOptionFieldEntity
|
||||
*/
|
||||
private $option_field;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $value
|
||||
*/
|
||||
function setValue($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NewsletterEntity
|
||||
*/
|
||||
function getNewsletter() {
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterEntity $newsletter
|
||||
*/
|
||||
function setNewsletter($newsletter) {
|
||||
$this->newsletter = $newsletter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NewsletterOptionFieldEntity
|
||||
*/
|
||||
function getOptionField() {
|
||||
return $this->option_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterOptionFieldEntity $option_field
|
||||
*/
|
||||
function setOptionField($option_field) {
|
||||
$this->option_field = $option_field;
|
||||
}
|
||||
}
|
57
lib/Entities/NewsletterOptionFieldEntity.php
Normal file
57
lib/Entities/NewsletterOptionFieldEntity.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Table(name="newsletter_option_fields")
|
||||
*/
|
||||
class NewsletterOptionFieldEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $newsletter_type;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getNewsletterType() {
|
||||
return $this->newsletter_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $newsletter_type
|
||||
*/
|
||||
function setNewsletterType($newsletter_type) {
|
||||
$this->newsletter_type = $newsletter_type;
|
||||
}
|
||||
}
|
51
lib/Entities/NewsletterSegmentEntity.php
Normal file
51
lib/Entities/NewsletterSegmentEntity.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Table(name="newsletter_segment")
|
||||
*/
|
||||
class NewsletterSegmentEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity", inversedBy="newsletter_segments")
|
||||
* @var NewsletterEntity
|
||||
*/
|
||||
private $newsletter;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="MailPoet\Entities\SegmentEntity")
|
||||
* @var SegmentEntity
|
||||
*/
|
||||
private $segment;
|
||||
|
||||
/**
|
||||
* @return NewsletterEntity
|
||||
*/
|
||||
function getNewsletter() {
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
function setNewsletter(NewsletterEntity $newsletter) {
|
||||
$this->newsletter = $newsletter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SegmentEntity
|
||||
*/
|
||||
function getSegment() {
|
||||
return $this->segment;
|
||||
}
|
||||
|
||||
function setSegment(SegmentEntity $segment) {
|
||||
$this->segment = $segment;
|
||||
}
|
||||
}
|
79
lib/Entities/SegmentEntity.php
Normal file
79
lib/Entities/SegmentEntity.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Table(name="segments")
|
||||
*/
|
||||
class SegmentEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use DeletedAtTrait;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
function setName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
function setDescription($description) {
|
||||
$this->description = $description;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\Models;
|
||||
use Carbon\Carbon;
|
||||
use MailPoet\Entities\NewsletterEntity;
|
||||
use MailPoet\Newsletter\Renderer\Renderer;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Tasks\Sending as SendingTask;
|
||||
@ -37,18 +38,18 @@ if (!defined('ABSPATH')) exit;
|
||||
|
||||
class Newsletter extends Model {
|
||||
public static $_table = MP_NEWSLETTERS_TABLE;
|
||||
const TYPE_AUTOMATIC = 'automatic';
|
||||
const TYPE_STANDARD = 'standard';
|
||||
const TYPE_WELCOME = 'welcome';
|
||||
const TYPE_NOTIFICATION = 'notification';
|
||||
const TYPE_NOTIFICATION_HISTORY = 'notification_history';
|
||||
const TYPE_AUTOMATIC = NewsletterEntity::TYPE_AUTOMATIC;
|
||||
const TYPE_STANDARD = NewsletterEntity::TYPE_STANDARD;
|
||||
const TYPE_WELCOME = NewsletterEntity::TYPE_WELCOME;
|
||||
const TYPE_NOTIFICATION = NewsletterEntity::TYPE_NOTIFICATION;
|
||||
const TYPE_NOTIFICATION_HISTORY = NewsletterEntity::TYPE_NOTIFICATION_HISTORY;
|
||||
// standard newsletters
|
||||
const STATUS_DRAFT = 'draft';
|
||||
const STATUS_SCHEDULED = 'scheduled';
|
||||
const STATUS_SENDING = 'sending';
|
||||
const STATUS_SENT = 'sent';
|
||||
const STATUS_DRAFT = NewsletterEntity::STATUS_DRAFT;
|
||||
const STATUS_SCHEDULED = NewsletterEntity::STATUS_SCHEDULED;
|
||||
const STATUS_SENDING = NewsletterEntity::STATUS_SENDING;
|
||||
const STATUS_SENT = NewsletterEntity::STATUS_SENT;
|
||||
// automatic newsletters status
|
||||
const STATUS_ACTIVE = 'active';
|
||||
const STATUS_ACTIVE = NewsletterEntity::STATUS_ACTIVE;
|
||||
|
||||
private $emoji;
|
||||
|
||||
|
Reference in New Issue
Block a user