1 | <?php |
||
16 | class User |
||
17 | { |
||
18 | public const AVATAR_SIZE_SMALL = '24'; |
||
19 | public const AVATAR_SIZE_MEDIUM = '40'; |
||
20 | public const AVATAR_SIZE_LARGE = '80'; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | * |
||
25 | * @ORM\Column(name="id", type="integer") |
||
26 | * @ORM\Id |
||
27 | */ |
||
28 | private $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | * |
||
33 | * @ORM\Column(name="login", type="string", length=255, nullable=false) |
||
34 | */ |
||
35 | private $login; |
||
36 | |||
37 | /** |
||
38 | * @var string|null |
||
39 | * |
||
40 | * @ORM\Column(name="name", type="string", length=255, nullable=true) |
||
41 | */ |
||
42 | private $name; |
||
43 | |||
44 | /** |
||
45 | * @var \DateTime |
||
46 | * |
||
47 | * @ORM\Column(name="created_at", type="datetime") |
||
48 | */ |
||
49 | private $createdAt; |
||
50 | |||
51 | /** |
||
52 | * @var \DateTime |
||
53 | * |
||
54 | * @ORM\Column(name="updated_at", type="datetime", nullable=true) |
||
55 | */ |
||
56 | private $updatedAt; |
||
57 | |||
58 | /** |
||
59 | * @var bool |
||
60 | * |
||
61 | * @ORM\Column(name="public", type="boolean", nullable=false, options={"default": false}) |
||
62 | */ |
||
63 | private $public = false; |
||
64 | |||
65 | /** |
||
66 | * @var bool |
||
67 | * |
||
68 | * @ORM\Column(name="whitelist_only", type="boolean", nullable=false, options={"default": false}) |
||
69 | */ |
||
70 | private $whitelistOnly = false; |
||
71 | |||
72 | /** |
||
73 | * @var ArrayCollection|Subscription[] |
||
74 | * |
||
75 | * @ORM\OneToMany(targetEntity="Subscription", mappedBy="author", fetch="EXTRA_LAZY") |
||
76 | */ |
||
77 | private $subscribers; |
||
78 | |||
79 | /** |
||
80 | * @var ArrayCollection|Subscription[] |
||
81 | * |
||
82 | * @ORM\OneToMany(targetEntity="Subscription", mappedBy="subscriber", fetch="EXTRA_LAZY") |
||
83 | */ |
||
84 | private $subscriptions; |
||
85 | |||
86 | /** |
||
87 | * @var ArrayCollection|SubscriptionEvent[] |
||
88 | * |
||
89 | * @ORM\OneToMany(targetEntity="SubscriptionEvent", mappedBy="author", fetch="EXTRA_LAZY") |
||
90 | */ |
||
91 | private $newSubscriberEvents; |
||
92 | |||
93 | /** |
||
94 | * @var bool |
||
95 | * |
||
96 | * @ORM\Column(name="is_removed", type="boolean", options={"default": false}) |
||
97 | */ |
||
98 | private $removed = false; |
||
99 | |||
100 | |||
101 | public function __construct(int $id, \DateTime $createdAt = null, string $login = null, string $name = null) |
||
102 | { |
||
103 | $this->id = $id; |
||
104 | $this->login = $login; |
||
105 | $this->name = $name; |
||
106 | 3 | $this->createdAt = $createdAt ?: new \DateTime(); |
|
107 | |||
108 | 3 | $this->subscribers = new ArrayCollection(); |
|
109 | $this->subscriptions = new ArrayCollection(); |
||
110 | $this->newSubscriberEvents = new ArrayCollection(); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @ORM\PreUpdate |
||
115 | */ |
||
116 | public function preUpdate(): void |
||
117 | { |
||
118 | $this->updatedAt = new \DateTime(); |
||
119 | } |
||
120 | |||
121 | public function getId(): int |
||
125 | |||
126 | |||
127 | public function getLogin(): string |
||
131 | |||
132 | public function getName(): ?string |
||
136 | 1 | ||
137 | public function updateLoginAndName(string $login, ?string $name): self |
||
144 | |||
145 | public function addSubscriber(Subscription $subscribers): self |
||
151 | |||
152 | public function removeSubscriber(Subscription $subscribers) |
||
156 | |||
157 | /** |
||
158 | * @return Subscription[]|ArrayCollection |
||
159 | */ |
||
160 | public function getSubscribers(): ArrayCollection |
||
164 | |||
165 | /** |
||
166 | * @return Subscription[]|ArrayCollection |
||
167 | */ |
||
168 | public function getSubscriptions(): ArrayCollection |
||
172 | |||
173 | public function addNewSubscriberEvent(SubscriptionEvent $newSubscriberEvents): self |
||
179 | |||
180 | /** |
||
181 | * @return SubscriptionEvent[]|ArrayCollection |
||
182 | */ |
||
183 | public function getNewSubscriberEvents(): ArrayCollection |
||
187 | |||
188 | public function getCreatedAt(): \DateTime |
||
192 | |||
193 | public function getUpdatedAt(): ?\DateTime |
||
197 | |||
198 | public function updatePrivacy(?bool $public, ?bool $whitelistOnly): void |
||
203 | |||
204 | public function isPublic(): ?bool |
||
208 | |||
209 | public function isWhitelistOnly(): ?bool |
||
213 | |||
214 | public function isRemoved(): bool |
||
218 | |||
219 | public function markAsRemoved(): void |
||
223 | |||
224 | public function restore(): void |
||
228 | } |
||
229 |