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