1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-27 17:28:39 +00:00

add relation between entry and tag

This commit is contained in:
Nicolas Lœuillet 2015-02-20 20:29:33 +01:00
parent 6d37a7e6c1
commit 0a018fe039
6 changed files with 53 additions and 122 deletions

View file

@ -2,6 +2,7 @@
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;
@ -118,12 +119,22 @@ class Entry
*/
private $user;
/**
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "merge"})
* @ORM\JoinTable(name="tags_entries",
* joinColumns={@ORM\JoinColumn(name="entry_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
* )
*/
private $tags;
/*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
$this->tags = new ArrayCollection();
}
/**
@ -381,4 +392,20 @@ class Entry
{
$this->isPublic = $isPublic;
}
/**
* @return ArrayCollection<Tag>
*/
public function getTags()
{
return $this->tags;
}
/**
* @param Tag $tag
*/
public function addTag(Tag $tag)
{
$this->tags[] = $tag;
}
}