X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=5e608f05d909a57d99ab0b8a4977721d510e5ae9;hb=bca5485946a72942c76dbb65c29e40818dca4976;hp=f11a77860450105624623e5eae91869fbac09849;hpb=8eedc8cfacc07e998f6f0bcdfe5b76496a215ea2;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index f11a7786..5e608f05 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -4,11 +4,15 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Validator\Constraints as Assert; 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. @@ -98,13 +102,12 @@ class 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 @@ -161,6 +164,8 @@ class Entry private $isPublic; /** + * @Exclude + * * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") * * @Groups({"export_all"}) @@ -168,7 +173,7 @@ class Entry private $user; /** - * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) + * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "remove"}) * @ORM\JoinTable * * @Groups({"entries_for_user", "export_all"}) @@ -336,6 +341,33 @@ class Entry 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 */ @@ -366,19 +398,19 @@ class Entry } /** - * @return string + * @return ArrayCollection */ - 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; } /**