-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathSubscriberList.php
More file actions
243 lines (196 loc) · 6.12 KB
/
SubscriberList.php
File metadata and controls
243 lines (196 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
declare(strict_types=1);
namespace PhpList\Core\Domain\Subscription\Model;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use PhpList\Core\Domain\Common\Model\Interfaces\CreationDate;
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
use PhpList\Core\Domain\Common\Model\Interfaces\Identity;
use PhpList\Core\Domain\Common\Model\Interfaces\ModificationDate;
use PhpList\Core\Domain\Common\Model\Interfaces\OwnableInterface;
use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Messaging\Model\ListMessage;
use PhpList\Core\Domain\Subscription\Repository\SubscriberListRepository;
use Symfony\Component\Serializer\Attribute\MaxDepth;
/**
* This class represents an administrator who can log to the system, is allowed to administer
* selected lists (as the owner), send campaigns to these lists and edit subscribers.
* @author Oliver Klee <oliver@phplist.com>
* @author Tatevik Grigoryan <tatevik@phplist.com>
*/
#[ORM\Entity(repositoryClass: SubscriberListRepository::class)]
#[ORM\Table(name: 'phplist_list')]
#[ORM\Index(name: 'phplist_list_nameidx', columns: ['name'])]
#[ORM\Index(name: 'phplist_list_listorderidx', columns: ['listorder'])]
#[ORM\HasLifecycleCallbacks]
class SubscriberList implements DomainModel, Identity, CreationDate, ModificationDate, OwnableInterface
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue]
private ?int $id = null;
#[ORM\Column]
private string $name = '';
#[ORM\Column(name: 'rssfeed', type: 'string', length: 255, nullable: true)]
private ?string $rssFeed = null;
#[ORM\Column]
private ?string $description = '';
#[ORM\Column(name: 'entered', type: 'datetime', nullable: true)]
protected ?DateTime $createdAt = null;
#[ORM\Column(name: 'modified', type: 'datetime')]
private ?DateTime $updatedAt = null;
#[ORM\Column(name: 'listorder', type: 'integer', nullable: true)]
private ?int $listPosition;
#[ORM\Column(name: 'prefix', length: 10, nullable: true)]
private ?string $subjectPrefix;
#[ORM\Column(name: 'active', type: 'boolean')]
private bool $public;
#[ORM\Column]
private ?string $category = '';
#[ORM\ManyToOne(targetEntity: Administrator::class, inversedBy: 'ownedLists')]
#[ORM\JoinColumn(name: 'owner')]
private ?Administrator $owner = null;
#[ORM\OneToMany(
targetEntity: Subscription::class,
mappedBy: 'subscriberList',
cascade: ['remove'],
orphanRemoval: true,
)]
#[MaxDepth(1)]
private Collection $subscriptions;
#[ORM\OneToMany(targetEntity: ListMessage::class, mappedBy: 'subscriberList')]
private Collection $listMessages;
public function __construct()
{
$this->subscriptions = new ArrayCollection();
$this->listMessages = new ArrayCollection();
$this->createdAt = new DateTime();
$this->listPosition = 0;
$this->subjectPrefix = '';
$this->category = '';
$this->public = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getRssFeed(): ?string
{
return $this->rssFeed;
}
public function setRssFeed(?string $rssFeed): self
{
$this->rssFeed = $rssFeed;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getListPosition(): ?int
{
return $this->listPosition;
}
public function setListPosition(?int $listPosition): self
{
$this->listPosition = $listPosition;
return $this;
}
public function getSubjectPrefix(): ?string
{
return $this->subjectPrefix;
}
public function setSubjectPrefix(?string $subjectPrefix): self
{
$this->subjectPrefix = $subjectPrefix;
return $this;
}
public function isPublic(): bool
{
return $this->public ?? false;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getOwner(): ?Administrator
{
return $this->owner;
}
public function setOwner(Administrator $owner): self
{
$this->owner = $owner;
return $this;
}
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
public function addSubscription(Subscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions->add($subscription);
$subscription->setSubscriberList($this);
}
return $this;
}
public function removeSubscription(Subscription $subscription): self
{
if ($this->subscriptions->removeElement($subscription)) {
$subscription->setSubscriberList(null);
}
return $this;
}
public function getSubscribers(): Collection
{
$result = new ArrayCollection();
foreach ($this->subscriptions as $subscription) {
$result->add($subscription->getSubscriber());
}
return $result;
}
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function updateUpdatedAt(): void
{
$this->updatedAt = new DateTime();
}
public function getListMessages(): Collection
{
return $this->listMessages;
}
}