diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-26 09:41:42 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 21:09:15 +0100 |
commit | 092ca70725b0263390e45c46f93828c613eca3f0 (patch) | |
tree | 7b9fe8b824505b645bda6896a3589f09e25b1ccc /src/Wallabag/CoreBundle/Entity | |
parent | a36737f4859e3acbddf5cfe90c279ba725a6d88a (diff) | |
download | wallabag-092ca70725b0263390e45c46f93828c613eca3f0.tar.gz wallabag-092ca70725b0263390e45c46f93828c613eca3f0.tar.zst wallabag-092ca70725b0263390e45c46f93828c613eca3f0.zip |
add relation between user and tags, tests are broken
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 5 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Tag.php | 8 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/User.php | 30 |
3 files changed, 40 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 229a6704..75aeae84 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -406,4 +406,9 @@ class Entry | |||
406 | $this->tags[] = $tag; | 406 | $this->tags[] = $tag; |
407 | $tag->addEntry($this); | 407 | $tag->addEntry($this); |
408 | } | 408 | } |
409 | |||
410 | public function removeTag(Tag $tag) | ||
411 | { | ||
412 | $this->tags->removeElement($tag); | ||
413 | } | ||
409 | } | 414 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 5aed1fa0..29a5e4b5 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php | |||
@@ -41,8 +41,14 @@ class Tag | |||
41 | */ | 41 | */ |
42 | private $entries; | 42 | private $entries; |
43 | 43 | ||
44 | public function __construct() | 44 | /** |
45 | * @ORM\ManyToOne(targetEntity="User", inversedBy="tags") | ||
46 | */ | ||
47 | private $user; | ||
48 | |||
49 | public function __construct(User $user) | ||
45 | { | 50 | { |
51 | $this->user = $user; | ||
46 | $this->entries = new ArrayCollection(); | 52 | $this->entries = new ArrayCollection(); |
47 | } | 53 | } |
48 | /** | 54 | /** |
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index 5589c039..f05c8760 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php | |||
@@ -101,10 +101,17 @@ class User implements AdvancedUserInterface, \Serializable | |||
101 | */ | 101 | */ |
102 | private $config; | 102 | private $config; |
103 | 103 | ||
104 | /** | ||
105 | * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) | ||
106 | */ | ||
107 | private $tags; | ||
108 | |||
104 | public function __construct() | 109 | public function __construct() |
105 | { | 110 | { |
106 | $this->salt = md5(uniqid(null, true)); | 111 | $this->isActive = true; |
107 | $this->entries = new ArrayCollection(); | 112 | $this->salt = md5(uniqid(null, true)); |
113 | $this->entries = new ArrayCollection(); | ||
114 | $this->tags = new ArrayCollection(); | ||
108 | } | 115 | } |
109 | 116 | ||
110 | /** | 117 | /** |
@@ -279,6 +286,25 @@ class User implements AdvancedUserInterface, \Serializable | |||
279 | } | 286 | } |
280 | 287 | ||
281 | /** | 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 | /** | ||
282 | * @inheritDoc | 308 | * @inheritDoc |
283 | */ | 309 | */ |
284 | public function eraseCredentials() | 310 | public function eraseCredentials() |