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