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
154 public function setTitle($title)
156 $this->title
= $title;
166 public function getTitle()
178 public function setUrl($url)
190 public function getUrl()
198 * @param string $isArchived
202 public function setArchived($isArchived)
204 $this->isArchived
= $isArchived;
214 public function isArchived()
216 return $this->isArchived
;
219 public function toggleArchive()
221 $this->isArchived
= $this->isArchived() ^
1;
229 * @param string $isStarred
233 public function setStarred($isStarred)
235 $this->isStarred
= $isStarred;
245 public function isStarred()
247 return $this->isStarred
;
250 public function toggleStar()
252 $this->isStarred
= $this->isStarred() ^
1;
260 * @param string $content
264 public function setContent($content)
266 $this->content
= $content;
276 public function getContent()
278 return $this->content
;
284 public function getUser()
292 public function getCreatedAt()
294 return $this->createdAt
;
300 public function getUpdatedAt()
302 return $this->updatedAt
;
309 public function timestamps()
311 if (is_null($this->createdAt
)) {
312 $this->createdAt
= new \
DateTime();
315 $this->updatedAt
= new \
DateTime();
321 public function getComments()
323 return $this->comments
;
327 * @param string $comments
329 public function setComments($comments)
331 $this->comments
= $comments;
337 public function getMimetype()
339 return $this->mimetype
;
343 * @param string $mimetype
345 public function setMimetype($mimetype)
347 $this->mimetype
= $mimetype;
353 public function getReadingTime()
355 return $this->readingTime
;
359 * @param int $readingTime
361 public function setReadingTime($readingTime)
363 $this->readingTime
= $readingTime;
369 public function getDomainName()
371 return $this->domainName
;
375 * @param string $domainName
377 public function setDomainName($domainName)
379 $this->domainName
= $domainName;
385 public function isPublic()
387 return $this->isPublic
;
391 * @param bool $isPublic
393 public function setPublic($isPublic)
395 $this->isPublic
= $isPublic;
399 * @return ArrayCollection<Tag>
401 public function getTags()
409 public function addTag(Tag
$tag)
411 $this->tags
[] = $tag;
412 $tag->addEntry($this);
415 public function removeTag(Tag
$tag)
417 $this->tags
->removeElement($tag);