Pārlūkot izejas kodu

Evolution #164: Proposition de tag sur un élément

bastien 13 gadus atpakaļ
vecāks
revīzija
03694f457c

+ 7 - 0
src/Muzich/CoreBundle/Entity/Element.php Parādīt failu

@@ -75,6 +75,13 @@ class Element
75 75
   protected $elements_favorites;
76 76
   
77 77
   /**
78
+   * Propositions de tags
79
+   * 
80
+   * @ORM\OneToMany(targetEntity="ElementTagsProposition", mappedBy="element")
81
+   */
82
+  protected $tags_propositions;
83
+  
84
+  /**
78 85
    * L'url est l'url du media. 
79 86
    * 
80 87
    * @ORM\Column(type="string", length=1024)

+ 180 - 0
src/Muzich/CoreBundle/Entity/ElementTagsProposition.php Parādīt failu

@@ -0,0 +1,180 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Entity;
4
+
5
+use Doctrine\ORM\Mapping as ORM;
6
+use Gedmo\Mapping\Annotation as Gedmo;
7
+use Symfony\Component\Validator\Constraints as Assert;
8
+use Muzich\CoreBundle\Validator as MuzichAssert;
9
+
10
+/**
11
+ * Cette table permet aux utilisateurs de proposer des tags sur des éléments
12
+ * ne leurs appartenant pas.
13
+ * 
14
+ * @ORM\Entity
15
+ * @ORM\Entity(repositoryClass="Muzich\CoreBundle\Repository\ElementTagsProposition")
16
+ * 
17
+ */
18
+class ElementTagsProposition
19
+{
20
+  
21
+  /**
22
+   * @ORM\Id
23
+   * @ORM\Column(type="integer")
24
+   * @ORM\GeneratedValue(strategy="AUTO")
25
+   * @var type int
26
+   */
27
+  protected $id;
28
+
29
+  /**
30
+   * Propriétaire de la proposition
31
+   * 
32
+   * @ORM\ManyToOne(targetEntity="User", inversedBy="element_tags_propositions")
33
+   * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
34
+   */
35
+  protected $user;
36
+
37
+  /**
38
+   * Propriétaire de la proposition
39
+   * 
40
+   * @ORM\ManyToOne(targetEntity="Element", inversedBy="tags_propositions")
41
+   * @ORM\JoinColumn(name="element_id", referencedColumnName="id")
42
+   */
43
+  protected $element;
44
+  
45
+  /**
46
+   * Cet attribut stocke la liste des tags liés a cette proposition.
47
+   * 
48
+   * @ORM\ManyToMany(targetEntity="Tag", inversedBy="propositions")
49
+   * @ORM\JoinTable(name="element_tags_proposition_tags_rel")
50
+   * @MuzichAssert\Tags()
51
+   */
52
+  protected $tags;
53
+  
54
+  /**
55
+   * @var datetime $created
56
+   *
57
+   * @Gedmo\Timestampable(on="create")
58
+   * @ORM\Column(type="datetime")
59
+   */
60
+  private $created;
61
+
62
+  /**
63
+   * @var datetime $updated
64
+   *
65
+   * @ORM\Column(type="datetime")
66
+   * @Gedmo\Timestampable(on="update")
67
+   */
68
+  private $updated;
69
+  
70
+    
71
+  /**
72
+   * Get id
73
+   *
74
+   * @return integer 
75
+   */
76
+  public function getId()
77
+  {
78
+    return $this->id;
79
+  }
80
+
81
+  /**
82
+   * Set created
83
+   *
84
+   * @param datetime $created
85
+   */
86
+  public function setCreated($created)
87
+  {
88
+    $this->created = $created;
89
+  }
90
+
91
+  /**
92
+   * Get created
93
+   *
94
+   * @return datetime 
95
+   */
96
+  public function getCreated()
97
+  {
98
+    return $this->created;
99
+  }
100
+
101
+  /**
102
+   * Set updated
103
+   *
104
+   * @param datetime $updated
105
+   */
106
+  public function setUpdated($updated)
107
+  {
108
+    $this->updated = $updated;
109
+  }
110
+
111
+  /**
112
+   * Get updated
113
+   *
114
+   * @return datetime 
115
+   */
116
+  public function getUpdated()
117
+  {
118
+    return $this->updated;
119
+  }
120
+
121
+  /**
122
+   * Set user
123
+   *
124
+   * @param Muzich\CoreBundle\Entity\User $user
125
+   */
126
+  public function setUser(\Muzich\CoreBundle\Entity\User $user)
127
+  {
128
+    $this->user = $user;
129
+  }
130
+
131
+  /**
132
+   * Get user
133
+   *
134
+   * @return Muzich\CoreBundle\Entity\User 
135
+   */
136
+  public function getUser()
137
+  {
138
+    return $this->user;
139
+  }
140
+
141
+  /**
142
+   * Set element
143
+   *
144
+   * @param Muzich\CoreBundle\Entity\Element $element
145
+   */
146
+  public function setElement(\Muzich\CoreBundle\Entity\Element $element)
147
+  {
148
+    $this->element = $element;
149
+  }
150
+
151
+  /**
152
+   * Get element
153
+   *
154
+   * @return Muzich\CoreBundle\Entity\Element 
155
+   */
156
+  public function getElement()
157
+  {
158
+    return $this->element;
159
+  }
160
+
161
+  /**
162
+   * Add tags
163
+   *
164
+   * @param Muzich\CoreBundle\Entity\Tag $tags
165
+   */
166
+  public function addTag(\Muzich\CoreBundle\Entity\Tag $tags)
167
+  {
168
+    $this->tags[] = $tags;
169
+  }
170
+
171
+  /**
172
+   * Get tags
173
+   *
174
+   * @return Doctrine\Common\Collections\Collection 
175
+   */
176
+  public function getTags()
177
+  {
178
+    return $this->tags;
179
+  }
180
+}

+ 7 - 0
src/Muzich/CoreBundle/Entity/Tag.php Parādīt failu

@@ -33,6 +33,13 @@ class Tag
33 33
   protected $elements;
34 34
   
35 35
   /**
36
+   * Cet attribu stocke la liste des propositions de tags liés a ce tag.
37
+   * 
38
+   * @ORM\ManyToMany(targetEntity="ElementTagsProposition", mappedBy="tags")
39
+   */
40
+  protected $propositions;
41
+  
42
+  /**
36 43
    * Cet attribu stocke les enregistrements UsersTagsFavorites liés
37 44
    * a ce Tag dans le cadre des Tags favoris de l'user.
38 45
    * 

+ 28 - 0
src/Muzich/CoreBundle/Entity/User.php Parādīt failu

@@ -10,6 +10,7 @@ use Doctrine\ORM\EntityManager;
10 10
 use Muzich\CoreBundle\Entity\UsersTagsFavorites;
11 11
 use Symfony\Component\Validator\Constraints as Assert;
12 12
 use Muzich\CoreBundle\Validator as MuzichAssert;
13
+use Muzich\CoreBundle\Entity\ElementTagsProposition;
13 14
 
14 15
 /**
15 16
  * Cet entité est l'utilisateur ayant effectué la requête.
@@ -70,6 +71,13 @@ class User extends BaseUser
70 71
   protected $elements;
71 72
   
72 73
   /**
74
+   * Liste des propositions de tags effectués par cet utilisateur
75
+   * 
76
+   * @ORM\OneToMany(targetEntity="ElementTagsProposition", mappedBy="user")
77
+   */
78
+  protected $element_tags_propositions;
79
+  
80
+  /**
73 81
    * Users que cet utilisateur suit.
74 82
    * 
75 83
    * @ORM\OneToMany(targetEntity="FollowUser", mappedBy="follower")
@@ -232,6 +240,26 @@ class User extends BaseUser
232 240
   }
233 241
 
234 242
   /**
243
+   * Add elements
244
+   *
245
+   * @param Element $elements
246
+   */
247
+  public function addElementTagsProposition(ElementTagsProposition $proposition)
248
+  {
249
+    $this->element_tags_propositions[] = $proposition;
250
+  }
251
+
252
+  /**
253
+   * Get elements
254
+   *
255
+   * @return Doctrine\Common\Collections\Collection 
256
+   */
257
+  public function getElementTagsPropositions()
258
+  {
259
+    return $this->element_tags_propositions;
260
+  }
261
+
262
+  /**
235 263
    * Add followeds_users
236 264
    *
237 265
    * @param FollowUser $followedsUsers

+ 10 - 0
src/Muzich/CoreBundle/Repository/ElementTagsPropositionRepository.php Parādīt failu

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Repository;
4
+
5
+use Doctrine\ORM\EntityRepository;
6
+
7
+class ElementTagsPropositionRepository extends EntityRepository
8
+{
9
+    
10
+}