Parcourir la source

A la relation entre l'Element et le Group.

bastien il y a 13 ans
Parent
révision
329300aa9c

+ 28 - 0
src/Muzich/CoreBundle/Entity/Element.php Voir le fichier

@@ -47,6 +47,14 @@ class Element
47 47
    * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
48 48
    */
49 49
   protected $owner;
50
+
51
+  /**
52
+   * Groupe de l'élément
53
+   * 
54
+   * @ORM\ManyToOne(targetEntity="Group", inversedBy="elements")
55
+   * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
56
+   */
57
+  protected $group = null;
50 58
   
51 59
   /**
52 60
    * Cet attribu stocke les enregistrements UsersElementsFavorites liés
@@ -237,4 +245,24 @@ class Element
237 245
   {
238 246
       return $this->elements_favorites;
239 247
   }
248
+
249
+  /**
250
+   * Set group
251
+   *
252
+   * @param Group $group
253
+   */
254
+  public function setGroup(Group $group)
255
+  {
256
+      $this->group = $group;
257
+  }
258
+
259
+  /**
260
+   * Get group
261
+   *
262
+   * @return Group 
263
+   */
264
+  public function getGroup()
265
+  {
266
+      return $this->group;
267
+  }
240 268
 }

+ 28 - 0
src/Muzich/CoreBundle/Entity/Group.php Voir le fichier

@@ -65,6 +65,14 @@ class Group
65 65
    * @ORM\OneToMany(targetEntity="GroupsTagsFavorites", mappedBy="group")
66 66
    */
67 67
   protected $tags;
68
+  
69
+  /**
70
+   * Cet attribut contient les enregistrements Element lié 
71
+   * a ce Groupe.
72
+   * 
73
+   * @ORM\OneToMany(targetEntity="Element", mappedBy="group")
74
+   */
75
+  protected $elements;
68 76
 
69 77
   /**
70 78
    * 
@@ -184,4 +192,24 @@ class Group
184 192
   {
185 193
     return $this->tags;
186 194
   }
195
+
196
+  /**
197
+   * Add elements
198
+   *
199
+   * @param Element $elements
200
+   */
201
+  public function addElement(Element $elements)
202
+  {
203
+      $this->elements[] = $elements;
204
+  }
205
+
206
+  /**
207
+   * Get elements
208
+   *
209
+   * @return Doctrine\Common\Collections\Collection 
210
+   */
211
+  public function getElements()
212
+  {
213
+      return $this->elements;
214
+  }
187 215
 }