X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=61d01bdcdadd5f0a52ceb3e66f08ae1eb0228cb9;hb=927c9e796ff6fad2bf82a965234f52932cdee657;hp=bbb1fb53378d8eb62961aef0bb6ecc76d2bd4e46;hpb=15e4aea67842ae83f98d9864c5bdafa056381248;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index bbb1fb53..61d01bdc 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -5,14 +5,15 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Hateoas\Configuration\Annotation as Hateoas; -use JMS\Serializer\Annotation\Groups; -use JMS\Serializer\Annotation\XmlRoot; use JMS\Serializer\Annotation\Exclude; -use JMS\Serializer\Annotation\VirtualProperty; +use JMS\Serializer\Annotation\Groups; use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\VirtualProperty; +use JMS\Serializer\Annotation\XmlRoot; use Symfony\Component\Validator\Constraints as Assert; -use Wallabag\UserBundle\Entity\User; use Wallabag\AnnotationBundle\Entity\Annotation; +use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; +use Wallabag\UserBundle\Entity\User; /** * Entry. @@ -32,6 +33,8 @@ use Wallabag\AnnotationBundle\Entity\Annotation; */ class Entry { + use EntityTimestampsTrait; + /** @Serializer\XmlAttribute */ /** * @var int @@ -121,6 +124,24 @@ class Entry */ private $updatedAt; + /** + * @var \DateTime + * + * @ORM\Column(name="published_at", type="datetime", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $publishedAt; + + /** + * @var array + * + * @ORM\Column(name="published_by", type="array", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $publishedBy; + /** * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"}) * @ORM\JoinTable @@ -183,6 +204,15 @@ class Entry */ private $httpStatus; + /** + * @var array + * + * @ORM\Column(name="headers", type="array", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $headers; + /** * @Exclude * @@ -445,19 +475,6 @@ class Entry return $this->updatedAt; } - /** - * @ORM\PrePersist - * @ORM\PreUpdate - */ - public function timestamps() - { - if (is_null($this->createdAt)) { - $this->createdAt = new \DateTime(); - } - - $this->updatedAt = new \DateTime(); - } - /** * @return ArrayCollection */ @@ -523,7 +540,7 @@ class Entry } /** - * @return ArrayCollection + * @return ArrayCollection */ public function getTags() { @@ -566,6 +583,11 @@ class Entry $tag->addEntry($this); } + /** + * Remove the given tag from the entry (if the tag is associated). + * + * @param Tag $tag + */ public function removeTag(Tag $tag) { if (!$this->tags->contains($tag)) { @@ -576,6 +598,17 @@ class Entry $tag->removeEntry($this); } + /** + * Remove all assigned tags from the entry. + */ + public function removeAllTags() + { + foreach ($this->tags as $tag) { + $this->tags->removeElement($tag); + $tag->removeEntry($this); + } + } + /** * Set previewPicture. * @@ -658,7 +691,22 @@ class Entry } /** - * @return int + * Used in the entries filter so it's more explicit for the end user than the uid. + * Also used in the API. + * + * @VirtualProperty + * @SerializedName("is_public") + * @Groups({"entries_for_user"}) + * + * @return bool + */ + public function isPublic() + { + return null !== $this->uid; + } + + /** + * @return string */ public function getHttpStatus() { @@ -666,7 +714,7 @@ class Entry } /** - * @param int $httpStatus + * @param string $httpStatus * * @return Entry */ @@ -676,4 +724,64 @@ class Entry return $this; } + + /** + * @return \Datetime + */ + public function getPublishedAt() + { + return $this->publishedAt; + } + + /** + * @param \Datetime $publishedAt + * + * @return Entry + */ + public function setPublishedAt(\Datetime $publishedAt) + { + $this->publishedAt = $publishedAt; + + return $this; + } + + /** + * @return array + */ + public function getPublishedBy() + { + return $this->publishedBy; + } + + /** + * @param array $publishedBy + * + * @return Entry + */ + public function setPublishedBy($publishedBy) + { + $this->publishedBy = $publishedBy; + + return $this; + } + + /** + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * @param array $headers + * + * @return Entry + */ + public function setHeaders($headers) + { + $this->headers = $headers; + + return $this; + } }