aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-24 07:42:09 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-03-06 20:50:31 +0100
commit46bbd8d321e6a00131f0e6ed96fa6f3d693b3678 (patch)
tree331d511837716ec7a7956c35f51dc3a14a1ca11c /src/Wallabag/CoreBundle/Entity
parent6c87418ff013cfd03093c3f01e20518e580d80bb (diff)
downloadwallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.tar.gz
wallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.tar.zst
wallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.zip
relation between tags and entries
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php8
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php12
-rw-r--r--src/Wallabag/CoreBundle/Entity/TagsEntries.php81
3 files changed, 14 insertions, 87 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index e0d1b839..229a6704 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -120,11 +120,8 @@ class Entry
120 private $user; 120 private $user;
121 121
122 /** 122 /**
123 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "merge"}) 123 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"})
124 * @ORM\JoinTable(name="tags_entries", 124 * @ORM\JoinTable(name="entry_tags")
125 * joinColumns={@ORM\JoinColumn(name="entry_id", referencedColumnName="id")},
126 * inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
127 * )
128 */ 125 */
129 private $tags; 126 private $tags;
130 127
@@ -407,5 +404,6 @@ class Entry
407 public function addTag(Tag $tag) 404 public function addTag(Tag $tag)
408 { 405 {
409 $this->tags[] = $tag; 406 $this->tags[] = $tag;
407 $tag->addEntry($this);
410 } 408 }
411} 409}
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 1cdf4df0..5aed1fa0 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\XmlRoot; 6use JMS\Serializer\Annotation\XmlRoot;
7use JMS\Serializer\Annotation\ExclusionPolicy; 7use JMS\Serializer\Annotation\ExclusionPolicy;
8use JMS\Serializer\Annotation\Expose; 8use JMS\Serializer\Annotation\Expose;
9use Doctrine\Common\Collections\ArrayCollection;
9 10
10/** 11/**
11 * Tag 12 * Tag
@@ -36,10 +37,14 @@ class Tag
36 private $label; 37 private $label;
37 38
38 /** 39 /**
39 * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist", "merge"}) 40 * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
40 */ 41 */
41 private $entries; 42 private $entries;
42 43
44 public function __construct()
45 {
46 $this->entries = new ArrayCollection();
47 }
43 /** 48 /**
44 * Get id 49 * Get id
45 * 50 *
@@ -72,4 +77,9 @@ class Tag
72 { 77 {
73 return $this->label; 78 return $this->label;
74 } 79 }
80
81 public function addEntry(Entry $entry)
82 {
83 $this->entries[] = $entry;
84 }
75} 85}
diff --git a/src/Wallabag/CoreBundle/Entity/TagsEntries.php b/src/Wallabag/CoreBundle/Entity/TagsEntries.php
deleted file mode 100644
index 589f26f8..00000000
--- a/src/Wallabag/CoreBundle/Entity/TagsEntries.php
+++ /dev/null
@@ -1,81 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6
7/**
8 * TagsEntries
9 *
10 * @ORM\Table(name="tags_entries")
11 */
12class TagsEntries
13{
14 /**
15 * @var integer
16 *
17 * @ORM\Column(name="id", type="integer")
18 * @ORM\Id
19 * @ORM\GeneratedValue(strategy="AUTO")
20 */
21 private $id;
22
23 /**
24 *
25 * @ORM\ManyToOne(targetEntity="Entry", inversedBy="tags_entries")
26 * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
27 *
28 */
29 private $entryId;
30
31 /**
32 *
33 * @ORM\ManyToOne(targetEntity="Tag", inversedBy="tags_entries")
34 * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
35 *
36 */
37 private $tagId;
38
39 /**
40 * Get id
41 *
42 * @return integer
43 */
44 public function getId()
45 {
46 return $this->id;
47 }
48
49 /**
50 * @return mixed
51 */
52 public function getEntryId()
53 {
54 return $this->entryId;
55 }
56
57 /**
58 * @param mixed $entryId
59 */
60 public function setEntryId($entryId)
61 {
62 $this->entryId = $entryId;
63 }
64
65 /**
66 * @return mixed
67 */
68 public function getTagId()
69 {
70 return $this->tagId;
71 }
72
73 /**
74 * @param mixed $tagId
75 */
76 public function setTagId($tagId)
77 {
78 $this->tagId = $tagId;
79 }
80
81}