1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* User |
10
|
|
|
* |
11
|
|
|
* @ORM\Table(name="users", schema="users") |
12
|
|
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\UserRepository") |
13
|
|
|
* @ORM\HasLifecycleCallbacks |
14
|
|
|
*/ |
15
|
|
|
class User |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var integer |
19
|
|
|
* |
20
|
|
|
* @ORM\Column(name="id", type="integer") |
21
|
|
|
* @ORM\Id |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="login", type="string", length=255, nullable=false) |
29
|
|
|
*/ |
30
|
|
|
private $login; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
* |
35
|
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=true) |
36
|
|
|
*/ |
37
|
|
|
private $name; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \DateTime |
41
|
|
|
* |
42
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
43
|
|
|
*/ |
44
|
|
|
private $createdAt; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \DateTime |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=true) |
50
|
|
|
*/ |
51
|
|
|
private $updatedAt; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var ArrayCollection |
55
|
|
|
* |
56
|
|
|
* @ORM\OneToMany(targetEntity="Subscription", mappedBy="author") |
57
|
|
|
*/ |
58
|
|
|
private $subscribers; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var ArrayCollection |
62
|
|
|
* |
63
|
|
|
* @ORM\OneToMany(targetEntity="Subscription", mappedBy="subscriber") |
64
|
|
|
*/ |
65
|
|
|
private $subscriptions; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var ArrayCollection |
69
|
|
|
* |
70
|
|
|
* @ORM\OneToMany(targetEntity="SubscriptionEvent", mappedBy="subscriber") |
71
|
|
|
*/ |
72
|
|
|
private $newSubscriptionEvents; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var ArrayCollection |
76
|
|
|
* @ORM\OneToMany(targetEntity="SubscriptionEvent", mappedBy="author") |
77
|
|
|
*/ |
78
|
|
|
private $newSubscriberEvents; |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param int $id |
83
|
|
|
* @param string $login |
84
|
|
|
* @param string $name |
85
|
|
|
*/ |
86
|
2 |
|
public function __construct($id = null, $login = null, $name = null) |
87
|
|
|
{ |
88
|
2 |
|
$this->id = $id; |
89
|
2 |
|
$this->login = $login; |
90
|
2 |
|
$this->name = $name; |
91
|
|
|
|
92
|
2 |
|
$this->subscribers = new ArrayCollection(); |
93
|
2 |
|
$this->subscriptions = new ArrayCollection(); |
94
|
2 |
|
$this->newSubscriberEvents = new ArrayCollection(); |
95
|
2 |
|
$this->newSubscriptionEvents = new ArrayCollection(); |
96
|
2 |
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @ORM\PrePersist |
100
|
|
|
*/ |
101
|
|
|
public function onCreate() |
102
|
|
|
{ |
103
|
|
|
if (!$this->createdAt) { |
104
|
|
|
$this->createdAt = new \DateTime(); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @ORM\PreUpdate |
110
|
|
|
*/ |
111
|
|
|
public function preUpdate() |
112
|
|
|
{ |
113
|
|
|
$this->updatedAt = new \DateTime(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get id |
118
|
|
|
* |
119
|
|
|
* @return integer |
120
|
|
|
*/ |
121
|
3 |
|
public function getId() |
122
|
|
|
{ |
123
|
3 |
|
return $this->id; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Set id of user (for API services only) |
128
|
|
|
* |
129
|
|
|
* @param integer $id |
130
|
|
|
* @return User |
131
|
|
|
*/ |
132
|
|
|
public function setId($id) |
133
|
|
|
{ |
134
|
|
|
$this->id = $id; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set login |
141
|
|
|
* |
142
|
|
|
* @param string $login |
143
|
|
|
* @return User |
144
|
|
|
*/ |
145
|
2 |
|
public function setLogin($login) |
146
|
|
|
{ |
147
|
2 |
|
$this->login = $login; |
148
|
|
|
|
149
|
2 |
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Get login |
154
|
|
|
* |
155
|
|
|
* @return string |
156
|
|
|
*/ |
157
|
8 |
|
public function getLogin() |
158
|
|
|
{ |
159
|
8 |
|
return $this->login; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Set name |
164
|
|
|
* |
165
|
|
|
* @param string $name |
166
|
|
|
* @return User |
167
|
|
|
*/ |
168
|
|
|
public function setName($name) |
169
|
|
|
{ |
170
|
|
|
$this->name = $name; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Get name |
177
|
|
|
* |
178
|
|
|
* @return string |
179
|
|
|
*/ |
180
|
1 |
|
public function getName() |
181
|
|
|
{ |
182
|
1 |
|
return $this->name; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Add subscribers |
187
|
|
|
* |
188
|
|
|
* @param Subscription $subscribers |
189
|
|
|
* @return User |
190
|
|
|
*/ |
191
|
|
|
public function addSubscriber(Subscription $subscribers) |
192
|
|
|
{ |
193
|
|
|
$this->subscribers[] = $subscribers; |
194
|
|
|
|
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Remove subscribers |
200
|
|
|
* |
201
|
|
|
* @param Subscription $subscribers |
202
|
|
|
*/ |
203
|
|
|
public function removeSubscriber(Subscription $subscribers) |
204
|
|
|
{ |
205
|
|
|
$this->subscribers->removeElement($subscribers); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Get subscribers |
210
|
|
|
* |
211
|
|
|
* @return Subscription[]|ArrayCollection |
212
|
|
|
*/ |
213
|
|
|
public function getSubscribers() |
214
|
|
|
{ |
215
|
|
|
return $this->subscribers; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Add subscriptions |
220
|
|
|
* |
221
|
|
|
* @param Subscription $subscriptions |
222
|
|
|
* @return User |
223
|
|
|
*/ |
224
|
|
|
public function addSubscription(Subscription $subscriptions) |
225
|
|
|
{ |
226
|
|
|
$this->subscriptions[] = $subscriptions; |
227
|
|
|
|
228
|
|
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Remove subscriptions |
233
|
|
|
* |
234
|
|
|
* @param Subscription $subscriptions |
235
|
|
|
*/ |
236
|
|
|
public function removeSubscription(Subscription $subscriptions) |
237
|
|
|
{ |
238
|
|
|
$this->subscriptions->removeElement($subscriptions); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Get subscriptions |
243
|
|
|
* |
244
|
|
|
* @return ArrayCollection |
245
|
|
|
*/ |
246
|
|
|
public function getSubscriptions() |
247
|
|
|
{ |
248
|
|
|
return $this->subscriptions; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Add newSubscriptionEvents |
253
|
|
|
* |
254
|
|
|
* @param SubscriptionEvent $newSubscriptionEvents |
255
|
|
|
* @return User |
256
|
|
|
*/ |
257
|
|
|
public function addNewSubscriptionEvent(SubscriptionEvent $newSubscriptionEvents) |
258
|
|
|
{ |
259
|
|
|
$this->newSubscriptionEvents[] = $newSubscriptionEvents; |
260
|
|
|
|
261
|
|
|
return $this; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Remove newSubscriptionEvents |
266
|
|
|
* |
267
|
|
|
* @param SubscriptionEvent $newSubscriptionEvents |
268
|
|
|
*/ |
269
|
|
|
public function removeNewSubscriptionEvent(SubscriptionEvent $newSubscriptionEvents) |
270
|
|
|
{ |
271
|
|
|
$this->newSubscriptionEvents->removeElement($newSubscriptionEvents); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Get newSubscriptionEvents |
276
|
|
|
* |
277
|
|
|
* @return ArrayCollection |
278
|
|
|
*/ |
279
|
|
|
public function getNewSubscriptionEvents() |
280
|
|
|
{ |
281
|
|
|
return $this->newSubscriptionEvents; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Add newSubscriberEvents |
286
|
|
|
* |
287
|
|
|
* @param SubscriptionEvent $newSubscriberEvents |
288
|
|
|
* @return User |
289
|
|
|
*/ |
290
|
|
|
public function addNewSubscriberEvent(SubscriptionEvent $newSubscriberEvents) |
291
|
|
|
{ |
292
|
|
|
$this->newSubscriberEvents[] = $newSubscriberEvents; |
293
|
|
|
|
294
|
|
|
return $this; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* Remove newSubscriberEvents |
299
|
|
|
* |
300
|
|
|
* @param SubscriptionEvent $newSubscriberEvents |
301
|
|
|
*/ |
302
|
|
|
public function removeNewSubscriberEvent(SubscriptionEvent $newSubscriberEvents) |
303
|
|
|
{ |
304
|
|
|
$this->newSubscriberEvents->removeElement($newSubscriberEvents); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* Get newSubscriberEvents |
309
|
|
|
* |
310
|
|
|
* @return ArrayCollection |
311
|
|
|
*/ |
312
|
|
|
public function getNewSubscriberEvents() |
313
|
|
|
{ |
314
|
|
|
return $this->newSubscriberEvents; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @return \DateTime |
319
|
|
|
*/ |
320
|
|
|
public function getCreatedAt() |
321
|
|
|
{ |
322
|
|
|
return $this->createdAt; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @param \DateTime $createdAt |
327
|
|
|
* @return User |
328
|
|
|
*/ |
329
|
|
|
public function setCreatedAt($createdAt) |
330
|
|
|
{ |
331
|
|
|
$this->createdAt = $createdAt; |
332
|
|
|
return $this; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @return \DateTime |
337
|
|
|
*/ |
338
|
|
|
public function getUpdatedAt() |
339
|
|
|
{ |
340
|
|
|
return $this->updatedAt; |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
|