|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @ORM\Table(name="log", schema="subscriptions", indexes={ |
|
9
|
|
|
* @ORM\Index(name="author_idx", columns={"author_id"}), |
|
10
|
|
|
* @ORM\Index(name="subscriber_idx", columns={"subscriber_id"}), |
|
11
|
|
|
* @ORM\Index(name="date_idx", columns={"date"}) |
|
12
|
|
|
* }) |
|
13
|
|
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository", readOnly=true) |
|
14
|
|
|
*/ |
|
15
|
|
|
class SubscriptionEvent |
|
16
|
|
|
{ |
|
17
|
|
|
const ACTION_SUBSCRIBE = 'subscribe'; |
|
18
|
|
|
const ACTION_UNSUBSCRIBE = 'unsubscribe'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var int |
|
22
|
|
|
* |
|
23
|
|
|
* @ORM\Column(name="id", type="integer") |
|
24
|
|
|
* @ORM\Id |
|
25
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
26
|
|
|
*/ |
|
27
|
|
|
private $id; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var User Blog author |
|
31
|
|
|
* |
|
32
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriberEvents") |
|
33
|
|
|
* @ORM\JoinColumn(name="author_id", nullable=false) |
|
34
|
|
|
*/ |
|
35
|
|
|
private $author; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var User Blog subscriber |
|
39
|
|
|
* |
|
40
|
|
|
* @ORM\ManyToOne(targetEntity="User") |
|
41
|
|
|
* @ORM\JoinColumn(name="subscriber_id", nullable=false) |
|
42
|
|
|
*/ |
|
43
|
|
|
private $subscriber; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var \DateTime |
|
47
|
|
|
* |
|
48
|
|
|
* @ORM\Column(name="date", type="datetime", nullable=false) |
|
49
|
|
|
*/ |
|
50
|
|
|
private $date; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var string |
|
54
|
|
|
* |
|
55
|
|
|
* @ORM\Column(name="action", type="string", length=12, nullable=false) |
|
56
|
|
|
*/ |
|
57
|
|
|
private $action; |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param User $author |
|
62
|
|
|
* @param User $subscriber |
|
63
|
|
|
* @param string $action |
|
64
|
|
|
*/ |
|
65
|
|
|
public function __construct(User $author, User $subscriber, string $action = self::ACTION_SUBSCRIBE) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->author = $author; |
|
68
|
|
|
$this->subscriber = $subscriber; |
|
69
|
|
|
$this->action = $action; |
|
70
|
|
|
$this->date = new \DateTime(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getId(): int |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->id; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getDate(): \DateTime |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->date; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function getSubscriber(): User |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->subscriber; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getAuthor(): User |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->author; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function getAction(): string |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->action; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|