3 namespace Wallabag\CoreBundle\Entity
;
5 use Doctrine\Common\Collections\ArrayCollection
;
6 use Doctrine\ORM\Mapping
as ORM
;
7 use Symfony\Component\Validator\Constraints
as Assert
;
8 use Hateoas\Configuration\Annotation
as Hateoas
;
9 use JMS\Serializer\Annotation\XmlRoot
;
15 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository")
17 * @ORM\HasLifecycleCallbacks()
18 * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())")
22 /** @Serializer\XmlAttribute */
26 * @ORM\Column(name="id", type="integer")
28 * @ORM\GeneratedValue(strategy="AUTO")
35 * @ORM\Column(name="title", type="text", nullable=true)
43 * @ORM\Column(name="url", type="text", nullable=true)
50 * @ORM\Column(name="is_archived", type="boolean")
52 private $isArchived = false;
57 * @ORM\Column(name="is_starred", type="boolean")
59 private $isStarred = false;
64 * @ORM\Column(name="content", type="text", nullable=true)
71 * @ORM\Column(name="created_at", type="datetime")
78 * @ORM\Column(name="updated_at", type="datetime")
85 * @ORM\Column(name="comments", type="text", nullable=true)
92 * @ORM\Column(name="mimetype", type="text", nullable=true)
99 * @ORM\Column(name="reading_type", type="integer", nullable=true)
101 private $readingTime;
106 * @ORM\Column(name="domain_name", type="text", nullable=true)
113 * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false})
118 * @ORM\ManyToOne(targetEntity="User", inversedBy="entries")
123 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"})
131 public function __construct(User
$user)
134 $this->tags
= new ArrayCollection();
142 public function getId()
150 * @param string $title
153 public function setTitle($title)
155 $this->title
= $title;
165 public function getTitle()
176 public function setUrl($url)
188 public function getUrl()
196 * @param string $isArchived
199 public function setArchived($isArchived)
201 $this->isArchived
= $isArchived;
211 public function isArchived()
213 return $this->isArchived
;
216 public function toggleArchive()
218 $this->isArchived
= $this->isArchived() ^
1;
226 * @param string $isStarred
229 public function setStarred($isStarred)
231 $this->isStarred
= $isStarred;
241 public function isStarred()
243 return $this->isStarred
;
246 public function toggleStar()
248 $this->isStarred
= $this->isStarred() ^
1;
256 * @param string $content
259 public function setContent($content)
261 $this->content
= $content;
271 public function getContent()
273 return $this->content
;
279 public function getUser()
287 public function getCreatedAt()
289 return $this->createdAt
;
295 public function getUpdatedAt()
297 return $this->updatedAt
;
304 public function timestamps()
306 if (is_null($this->createdAt
)) {
307 $this->createdAt
= new \
DateTime();
310 $this->updatedAt
= new \
DateTime();
316 public function getComments()
318 return $this->comments
;
322 * @param string $comments
324 public function setComments($comments)
326 $this->comments
= $comments;
332 public function getMimetype()
334 return $this->mimetype
;
338 * @param string $mimetype
340 public function setMimetype($mimetype)
342 $this->mimetype
= $mimetype;
348 public function getReadingTime()
350 return $this->readingTime
;
354 * @param int $readingTime
356 public function setReadingTime($readingTime)
358 $this->readingTime
= $readingTime;
364 public function getDomainName()
366 return $this->domainName
;
370 * @param string $domainName
372 public function setDomainName($domainName)
374 $this->domainName
= $domainName;
380 public function isPublic()
382 return $this->isPublic
;
386 * @param boolean $isPublic
388 public function setPublic($isPublic)
390 $this->isPublic
= $isPublic;
394 * @return ArrayCollection<Tag>
396 public function getTags()
404 public function addTag(Tag
$tag)
406 $this->tags
[] = $tag;
407 $tag->addEntry($this);
410 public function removeTag(Tag
$tag)
412 $this->tags
->removeElement($tag);