diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 21:48:33 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 21:48:33 +0100 |
commit | f37d1427a1b75f9d7a2e273b2e9fb0e895a769ab (patch) | |
tree | e6ea5fb4786e843b970b14d5a96da8c32548a315 /src/Wallabag/CoreBundle/Entity/User.php | |
parent | 73b774438395d0ed74d0fd863194d2ebfb68d9ce (diff) | |
parent | 6e22bd737b2e543c85487864a9a25b0f2d5cc3f2 (diff) | |
download | wallabag-f37d1427a1b75f9d7a2e273b2e9fb0e895a769ab.tar.gz wallabag-f37d1427a1b75f9d7a2e273b2e9fb0e895a769ab.tar.zst wallabag-f37d1427a1b75f9d7a2e273b2e9fb0e895a769ab.zip |
Merge pull request #1110 from wallabag/v2-api-hypermedia
[WIP] API : hypermedia & tags
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/User.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/User.php | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index ed5cfe53..f05c8760 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php | |||
@@ -7,6 +7,8 @@ use Doctrine\ORM\Mapping as ORM; | |||
7 | use Symfony\Component\Security\Core\User\UserInterface; | 7 | use Symfony\Component\Security\Core\User\UserInterface; |
8 | use Symfony\Component\Security\Core\User\AdvancedUserInterface; | 8 | use Symfony\Component\Security\Core\User\AdvancedUserInterface; |
9 | use Symfony\Component\Validator\Constraints as Assert; | 9 | use Symfony\Component\Validator\Constraints as Assert; |
10 | use JMS\Serializer\Annotation\ExclusionPolicy; | ||
11 | use JMS\Serializer\Annotation\Expose; | ||
10 | 12 | ||
11 | /** | 13 | /** |
12 | * User | 14 | * User |
@@ -14,12 +16,14 @@ use Symfony\Component\Validator\Constraints as Assert; | |||
14 | * @ORM\Table(name="user") | 16 | * @ORM\Table(name="user") |
15 | * @ORM\Entity | 17 | * @ORM\Entity |
16 | * @ORM\HasLifecycleCallbacks() | 18 | * @ORM\HasLifecycleCallbacks() |
19 | * @ExclusionPolicy("all") | ||
17 | */ | 20 | */ |
18 | class User implements AdvancedUserInterface, \Serializable | 21 | class User implements AdvancedUserInterface, \Serializable |
19 | { | 22 | { |
20 | /** | 23 | /** |
21 | * @var integer | 24 | * @var integer |
22 | * | 25 | * |
26 | * @Expose | ||
23 | * @ORM\Column(name="id", type="integer") | 27 | * @ORM\Column(name="id", type="integer") |
24 | * @ORM\Id | 28 | * @ORM\Id |
25 | * @ORM\GeneratedValue(strategy="AUTO") | 29 | * @ORM\GeneratedValue(strategy="AUTO") |
@@ -97,10 +101,17 @@ class User implements AdvancedUserInterface, \Serializable | |||
97 | */ | 101 | */ |
98 | private $config; | 102 | private $config; |
99 | 103 | ||
104 | /** | ||
105 | * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) | ||
106 | */ | ||
107 | private $tags; | ||
108 | |||
100 | public function __construct() | 109 | public function __construct() |
101 | { | 110 | { |
102 | $this->salt = md5(uniqid(null, true)); | 111 | $this->isActive = true; |
103 | $this->entries = new ArrayCollection(); | 112 | $this->salt = md5(uniqid(null, true)); |
113 | $this->entries = new ArrayCollection(); | ||
114 | $this->tags = new ArrayCollection(); | ||
104 | } | 115 | } |
105 | 116 | ||
106 | /** | 117 | /** |
@@ -275,6 +286,25 @@ class User implements AdvancedUserInterface, \Serializable | |||
275 | } | 286 | } |
276 | 287 | ||
277 | /** | 288 | /** |
289 | * @param Entry $entry | ||
290 | * | ||
291 | * @return User | ||
292 | */ | ||
293 | public function addTag(Tag $tag) | ||
294 | { | ||
295 | $this->tags[] = $tag; | ||
296 | |||
297 | return $this; | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * @return ArrayCollection<Tag> | ||
302 | */ | ||
303 | public function getTags() | ||
304 | { | ||
305 | return $this->tags; | ||
306 | } | ||
307 | /** | ||
278 | * @inheritDoc | 308 | * @inheritDoc |
279 | */ | 309 | */ |
280 | public function eraseCredentials() | 310 | public function eraseCredentials() |