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\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
use Wallabag\UserBundle\Entity\User;
+use Wallabag\AnnotationBundle\Entity\Annotation;
/**
* Entry.
private $updatedAt;
/**
- * @var string
- *
- * @ORM\Column(name="comments", type="text", nullable=true)
+ * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
+ * @ORM\JoinTable
*
- * @Groups({"export_all"})
+ * @Groups({"entries_for_user", "export_all"})
*/
- private $comments;
+ private $annotations;
/**
* @var string
private $isPublic;
/**
+ * @Exclude
+ *
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
*
* @Groups({"export_all"})
return $this->user;
}
+ /**
+ * @VirtualProperty
+ * @SerializedName("user_name")
+ */
+ public function getUserName()
+ {
+ return $this->user->getUserName();
+ }
+
+ /**
+ * @VirtualProperty
+ * @SerializedName("user_email")
+ */
+ public function getUserEmail()
+ {
+ return $this->user->getEmail();
+ }
+
+ /**
+ * @VirtualProperty
+ * @SerializedName("user_id")
+ */
+ public function getUserId()
+ {
+ return $this->user->getId();
+ }
+
/**
* @return string
*/
}
/**
- * @return string
+ * @return ArrayCollection<Annotation>
*/
- public function getComments()
+ public function getAnnotations()
{
- return $this->comments;
+ return $this->annotations;
}
/**
- * @param string $comments
+ * @param Annotation $annotation
*/
- public function setComments($comments)
+ public function setAnnotation(Annotation $annotation)
{
- $this->comments = $comments;
+ $this->annotations[] = $annotation;
}
/**