Merge pull request #1786 from wallabag/v2-restrict-user-infos

API shows just what needed for user
This commit is contained in:
Nicolas Lœuillet 2016-03-14 06:15:46 +01:00
commit 17b3d026fd

View File

@ -7,6 +7,9 @@ use Doctrine\ORM\Mapping as ORM;
use Hateoas\Configuration\Annotation as Hateoas; use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation\Groups; use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\XmlRoot; 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 Symfony\Component\Validator\Constraints as Assert;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\AnnotationBundle\Entity\Annotation;
@ -161,6 +164,8 @@ class Entry
private $isPublic; private $isPublic;
/** /**
* @Exclude
*
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries")
* *
* @Groups({"export_all"}) * @Groups({"export_all"})
@ -336,6 +341,33 @@ class Entry
return $this->user; 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
*/ */