1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-10-20 19:52:09 +00:00

add relation between user and tags, tests are broken

This commit is contained in:
Nicolas Lœuillet 2015-02-26 09:41:42 +01:00
parent a36737f485
commit 092ca70725
7 changed files with 131 additions and 31 deletions

View file

@ -406,4 +406,9 @@ class Entry
$this->tags[] = $tag;
$tag->addEntry($this);
}
public function removeTag(Tag $tag)
{
$this->tags->removeElement($tag);
}
}

View file

@ -41,8 +41,14 @@ class Tag
*/
private $entries;
public function __construct()
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="tags")
*/
private $user;
public function __construct(User $user)
{
$this->user = $user;
$this->entries = new ArrayCollection();
}
/**

View file

@ -101,10 +101,17 @@ class User implements AdvancedUserInterface, \Serializable
*/
private $config;
/**
* @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
*/
private $tags;
public function __construct()
{
$this->salt = md5(uniqid(null, true));
$this->entries = new ArrayCollection();
$this->isActive = true;
$this->salt = md5(uniqid(null, true));
$this->entries = new ArrayCollection();
$this->tags = new ArrayCollection();
}
/**
@ -278,6 +285,25 @@ class User implements AdvancedUserInterface, \Serializable
return $this->entries;
}
/**
* @param Entry $entry
*
* @return User
*/
public function addTag(Tag $tag)
{
$this->tags[] = $tag;
return $this;
}
/**
* @return ArrayCollection<Tag>
*/
public function getTags()
{
return $this->tags;
}
/**
* @inheritDoc
*/