]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Entity; | |
4 | ||
5 | use Doctrine\ORM\Mapping as ORM; | |
6 | use Symfony\Component\Validator\Constraints as Assert; | |
7 | ||
8 | /** | |
9 | * Entry | |
10 | * | |
11 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository") | |
12 | * @ORM\Table(name="entry") | |
13 | * @ORM\HasLifecycleCallbacks() | |
14 | * | |
15 | */ | |
16 | class Entry | |
17 | { | |
18 | /** | |
19 | * @var integer | |
20 | * | |
21 | * @ORM\Column(name="id", type="integer") | |
22 | * @ORM\Id | |
23 | * @ORM\GeneratedValue(strategy="AUTO") | |
24 | */ | |
25 | private $id; | |
26 | ||
27 | /** | |
28 | * @var string | |
29 | * | |
30 | * @ORM\Column(name="title", type="text", nullable=true) | |
31 | */ | |
32 | private $title; | |
33 | ||
34 | /** | |
35 | * @var string | |
36 | * | |
37 | * @Assert\NotBlank() | |
38 | * @ORM\Column(name="url", type="text", nullable=true) | |
39 | */ | |
40 | private $url; | |
41 | ||
42 | /** | |
43 | * @var boolean | |
44 | * | |
45 | * @ORM\Column(name="is_archived", type="boolean") | |
46 | */ | |
47 | private $isArchived = false; | |
48 | ||
49 | /** | |
50 | * @var boolean | |
51 | * | |
52 | * @ORM\Column(name="is_starred", type="boolean") | |
53 | */ | |
54 | private $isStarred = false; | |
55 | ||
56 | /** | |
57 | * @var boolean | |
58 | * | |
59 | * @ORM\Column(name="is_deleted", type="boolean") | |
60 | */ | |
61 | private $isDeleted = false; | |
62 | ||
63 | /** | |
64 | * @var string | |
65 | * | |
66 | * @ORM\Column(name="content", type="text", nullable=true) | |
67 | */ | |
68 | private $content; | |
69 | ||
70 | /** | |
71 | * @var date | |
72 | * | |
73 | * @ORM\Column(name="created_at", type="datetime") | |
74 | */ | |
75 | private $createdAt; | |
76 | ||
77 | /** | |
78 | * @var date | |
79 | * | |
80 | * @ORM\Column(name="updated_at", type="datetime") | |
81 | */ | |
82 | private $updatedAt; | |
83 | ||
84 | /** | |
85 | * @var string | |
86 | * | |
87 | * @ORM\Column(name="comments", type="text", nullable=true) | |
88 | */ | |
89 | private $comments; | |
90 | ||
91 | /** | |
92 | * @var string | |
93 | * | |
94 | * @ORM\Column(name="mimetype", type="text", nullable=true) | |
95 | */ | |
96 | private $mimetype; | |
97 | ||
98 | /** | |
99 | * @var integer | |
100 | * | |
101 | * @ORM\Column(name="reading_type", type="integer", nullable=true) | |
102 | */ | |
103 | private $readingTime; | |
104 | ||
105 | /** | |
106 | * @var string | |
107 | * | |
108 | * @ORM\Column(name="domain_name", type="text", nullable=true) | |
109 | */ | |
110 | private $domainName; | |
111 | ||
112 | /** | |
113 | * @var boolean | |
114 | * | |
115 | * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false}) | |
116 | */ | |
117 | private $isPublic; | |
118 | ||
119 | /** | |
120 | * @ORM\ManyToOne(targetEntity="User", inversedBy="entries") | |
121 | */ | |
122 | private $user; | |
123 | ||
124 | /* | |
125 | * @param User $user | |
126 | */ | |
127 | public function __construct(User $user) | |
128 | { | |
129 | $this->user = $user; | |
130 | } | |
131 | ||
132 | /** | |
133 | * Get id | |
134 | * | |
135 | * @return integer | |
136 | */ | |
137 | public function getId() | |
138 | { | |
139 | return $this->id; | |
140 | } | |
141 | ||
142 | /** | |
143 | * Set title | |
144 | * | |
145 | * @param string $title | |
146 | * @return Entry | |
147 | */ | |
148 | public function setTitle($title) | |
149 | { | |
150 | $this->title = $title; | |
151 | ||
152 | return $this; | |
153 | } | |
154 | ||
155 | /** | |
156 | * Get title | |
157 | * | |
158 | * @return string | |
159 | */ | |
160 | public function getTitle() | |
161 | { | |
162 | return $this->title; | |
163 | } | |
164 | ||
165 | /** | |
166 | * Set url | |
167 | * | |
168 | * @param string $url | |
169 | * @return Entry | |
170 | */ | |
171 | public function setUrl($url) | |
172 | { | |
173 | $this->url = $url; | |
174 | ||
175 | return $this; | |
176 | } | |
177 | ||
178 | /** | |
179 | * Get url | |
180 | * | |
181 | * @return string | |
182 | */ | |
183 | public function getUrl() | |
184 | { | |
185 | return $this->url; | |
186 | } | |
187 | ||
188 | /** | |
189 | * Set isArchived | |
190 | * | |
191 | * @param string $isArchived | |
192 | * @return Entry | |
193 | */ | |
194 | public function setArchived($isArchived) | |
195 | { | |
196 | $this->isArchived = $isArchived; | |
197 | ||
198 | return $this; | |
199 | } | |
200 | ||
201 | /** | |
202 | * Get isArchived | |
203 | * | |
204 | * @return string | |
205 | */ | |
206 | public function isArchived() | |
207 | { | |
208 | return $this->isArchived; | |
209 | } | |
210 | ||
211 | public function toggleArchive() | |
212 | { | |
213 | $this->isArchived = $this->isArchived() ^ 1; | |
214 | ||
215 | return $this; | |
216 | } | |
217 | ||
218 | /** | |
219 | * Set isStarred | |
220 | * | |
221 | * @param string $isStarred | |
222 | * @return Entry | |
223 | */ | |
224 | public function setStarred($isStarred) | |
225 | { | |
226 | $this->isStarred = $isStarred; | |
227 | ||
228 | return $this; | |
229 | } | |
230 | ||
231 | /** | |
232 | * Get isStarred | |
233 | * | |
234 | * @return string | |
235 | */ | |
236 | public function isStarred() | |
237 | { | |
238 | return $this->isStarred; | |
239 | } | |
240 | ||
241 | public function toggleStar() | |
242 | { | |
243 | $this->isStarred = $this->isStarred() ^ 1; | |
244 | ||
245 | return $this; | |
246 | } | |
247 | ||
248 | /** | |
249 | * Set content | |
250 | * | |
251 | * @param string $content | |
252 | * @return Entry | |
253 | */ | |
254 | public function setContent($content) | |
255 | { | |
256 | $this->content = $content; | |
257 | ||
258 | return $this; | |
259 | } | |
260 | ||
261 | /** | |
262 | * Get content | |
263 | * | |
264 | * @return string | |
265 | */ | |
266 | public function getContent() | |
267 | { | |
268 | return $this->content; | |
269 | } | |
270 | ||
271 | /** | |
272 | * @return User | |
273 | */ | |
274 | public function getUser() | |
275 | { | |
276 | return $this->user; | |
277 | } | |
278 | ||
279 | /** | |
280 | * @return string | |
281 | */ | |
282 | public function isDeleted() | |
283 | { | |
284 | return $this->isDeleted; | |
285 | } | |
286 | ||
287 | /** | |
288 | * @param string $isDeleted | |
289 | */ | |
290 | public function setDeleted($isDeleted) | |
291 | { | |
292 | $this->isDeleted = $isDeleted; | |
293 | } | |
294 | ||
295 | /** | |
296 | * @return string | |
297 | */ | |
298 | public function getCreatedAt() | |
299 | { | |
300 | return $this->createdAt; | |
301 | } | |
302 | ||
303 | /** | |
304 | * @return string | |
305 | */ | |
306 | public function getUpdatedAt() | |
307 | { | |
308 | return $this->updatedAt; | |
309 | } | |
310 | ||
311 | /** | |
312 | * @ORM\PrePersist | |
313 | * @ORM\PreUpdate | |
314 | */ | |
315 | public function timestamps() | |
316 | { | |
317 | if (is_null($this->createdAt)) { | |
318 | $this->createdAt = new \DateTime(); | |
319 | } | |
320 | ||
321 | $this->updatedAt = new \DateTime(); | |
322 | } | |
323 | ||
324 | /** | |
325 | * @return string | |
326 | */ | |
327 | public function getComments() | |
328 | { | |
329 | return $this->comments; | |
330 | } | |
331 | ||
332 | /** | |
333 | * @param string $comments | |
334 | */ | |
335 | public function setComments($comments) | |
336 | { | |
337 | $this->comments = $comments; | |
338 | } | |
339 | ||
340 | /** | |
341 | * @return string | |
342 | */ | |
343 | public function getMimetype() | |
344 | { | |
345 | return $this->mimetype; | |
346 | } | |
347 | ||
348 | /** | |
349 | * @param string $mimetype | |
350 | */ | |
351 | public function setMimetype($mimetype) | |
352 | { | |
353 | $this->mimetype = $mimetype; | |
354 | } | |
355 | ||
356 | /** | |
357 | * @return int | |
358 | */ | |
359 | public function getReadingTime() | |
360 | { | |
361 | return $this->readingTime; | |
362 | } | |
363 | ||
364 | /** | |
365 | * @param int $readingTime | |
366 | */ | |
367 | public function setReadingTime($readingTime) | |
368 | { | |
369 | $this->readingTime = $readingTime; | |
370 | } | |
371 | ||
372 | /** | |
373 | * @return string | |
374 | */ | |
375 | public function getDomainName() | |
376 | { | |
377 | return $this->domainName; | |
378 | } | |
379 | ||
380 | /** | |
381 | * @param string $domainName | |
382 | */ | |
383 | public function setDomainName($domainName) | |
384 | { | |
385 | $this->domainName = $domainName; | |
386 | } | |
387 | ||
388 | /** | |
389 | * @return boolean | |
390 | */ | |
391 | public function isPublic() | |
392 | { | |
393 | return $this->isPublic; | |
394 | } | |
395 | ||
396 | /** | |
397 | * @param boolean $isPublic | |
398 | */ | |
399 | public function setPublic($isPublic) | |
400 | { | |
401 | $this->isPublic = $isPublic; | |
402 | } | |
403 | } |