forked from wallabag/wallabag
relation between tags and entries
This commit is contained in:
@ -120,11 +120,8 @@ 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")}
|
||||
* )
|
||||
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"})
|
||||
* @ORM\JoinTable(name="entry_tags")
|
||||
*/
|
||||
private $tags;
|
||||
|
||||
@ -407,5 +404,6 @@ class Entry
|
||||
public function addTag(Tag $tag)
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
$tag->addEntry($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation\XmlRoot;
|
||||
use JMS\Serializer\Annotation\ExclusionPolicy;
|
||||
use JMS\Serializer\Annotation\Expose;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* Tag
|
||||
@ -36,10 +37,14 @@ class Tag
|
||||
private $label;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist", "merge"})
|
||||
* @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
|
||||
*/
|
||||
private $entries;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->entries = new ArrayCollection();
|
||||
}
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@ -72,4 +77,9 @@ class Tag
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function addEntry(Entry $entry)
|
||||
{
|
||||
$this->entries[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* TagsEntries
|
||||
*
|
||||
* @ORM\Table(name="tags_entries")
|
||||
*/
|
||||
class TagsEntries
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Entry", inversedBy="tags_entries")
|
||||
* @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
|
||||
*
|
||||
*/
|
||||
private $entryId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Tag", inversedBy="tags_entries")
|
||||
* @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
|
||||
*
|
||||
*/
|
||||
private $tagId;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEntryId()
|
||||
{
|
||||
return $this->entryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $entryId
|
||||
*/
|
||||
public function setEntryId($entryId)
|
||||
{
|
||||
$this->entryId = $entryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTagId()
|
||||
{
|
||||
return $this->tagId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $tagId
|
||||
*/
|
||||
public function setTagId($tagId)
|
||||
{
|
||||
$this->tagId = $tagId;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user