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.
*/
class Entry
{
+ use EntityTimestampsTrait;
+
/** @Serializer\XmlAttribute */
/**
* @var int
/**
* @var array
*
- * @ORM\Column(name="published_by", type="json_array", nullable=true)
+ * @ORM\Column(name="published_by", type="array", nullable=true)
*
* @Groups({"entries_for_user", "export_all"})
*/
*/
private $httpStatus;
+ /**
+ * @var array
+ *
+ * @ORM\Column(name="headers", type="array", nullable=true)
+ *
+ * @Groups({"entries_for_user", "export_all"})
+ */
+ private $headers;
+
/**
* @Exclude
*
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<Annotation>
*/
}
/**
- * @return ArrayCollection<Tag>
+ * @return ArrayCollection
*/
public function getTags()
{
$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)) {
$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.
*
}
/**
- * @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()
{
}
/**
- * @param int $httpStatus
+ * @param string $httpStatus
*
* @return Entry
*/
}
/**
- * @return string
+ * @return array
*/
public function getPublishedBy()
{
}
/**
- * @param string $publishedBy
+ * @param array $publishedBy
*
* @return Entry
*/
return $this;
}
+
+ /**
+ * @return array
+ */
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+
+ /**
+ * @param array $headers
+ *
+ * @return Entry
+ */
+ public function setHeaders($headers)
+ {
+ $this->headers = $headers;
+
+ return $this;
+ }
}