Explorar el Código

As Groupes dans le modèle et de relations entre User et groupes.

bastien hace 13 años
padre
commit
d800d39a60

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 6976 - 0
app/logs/dev.log


+ 90 - 0
src/Muzich/CoreBundle/Entity/FollowGroup.php Ver fichero

@@ -0,0 +1,90 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Entity;
4
+
5
+use Doctrine\ORM\Mapping as ORM;
6
+use Doctrine\Common\Collections\ArrayCollection;
7
+
8
+/**
9
+ * Cet entité est le lien entre un User et un Group. Pour exprimer que
10
+ * le follower suit un Groupe.
11
+ * 
12
+ * @ORM\Entity
13
+ * @ORM\Table(name="follow_group")
14
+ */
15
+class FollowGroup
16
+{
17
+  
18
+  /**
19
+  * @ORM\Id
20
+  * @ORM\Column(type="integer")
21
+  * @ORM\generatedValue(strategy="AUTO")
22
+  */
23
+  protected $id;
24
+  
25
+  /**
26
+   * Ee suiveur
27
+   * 
28
+   * @ORM\ManyToOne(targetEntity="Muzich\UserBundle\Entity\User", inversedBy="followed_groups")
29
+   * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
30
+   */
31
+  protected $follower;
32
+  
33
+  /**
34
+   * Groupe suivis
35
+   * 
36
+   * @ORM\ManyToOne(targetEntity="Group", inversedBy="follower")
37
+   * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
38
+   */
39
+  protected $group;
40
+  
41
+  /**
42
+   * Get id
43
+   *
44
+   * @return integer 
45
+   */
46
+  public function getId()
47
+  {
48
+    return $this->id;
49
+  }
50
+
51
+  /**
52
+   * Set follower
53
+   *
54
+   * @param Muzich\UserBundle\Entity\User $follower
55
+   */
56
+  public function setFollower(Muzich\UserBundle\Entity\User $follower)
57
+  {
58
+    $this->follower = $follower;
59
+  }
60
+
61
+  /**
62
+   * Get follower
63
+   *
64
+   * @return Muzich\UserBundle\Entity\User 
65
+   */
66
+  public function getFollower()
67
+  {
68
+    return $this->follower;
69
+  }
70
+
71
+  /**
72
+   * Set group
73
+   *
74
+   * @param Group $group
75
+   */
76
+  public function setGroup(Group $group)
77
+  {
78
+    $this->group = $group;
79
+  }
80
+
81
+  /**
82
+   * Get group
83
+   *
84
+   * @return Group 
85
+   */
86
+  public function getGroup()
87
+  {
88
+    return $this->group;
89
+  }
90
+}

+ 159 - 0
src/Muzich/CoreBundle/Entity/Group.php Ver fichero

@@ -0,0 +1,159 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Entity;
4
+
5
+use Doctrine\ORM\Mapping as ORM;
6
+use \Doctrine\Common\Collections\ArrayCollection;
7
+
8
+/**
9
+ * Le groupe est une sorte de liste de diffusion, a laquelle les
10
+ * users peuvent s'abonner (follow). Un groupe peut tout aussi bien 
11
+ * être "Les fans de la tek du sud est" qu'un sound système, 
12
+ * un artiste ...
13
+ * 
14
+ * @ORM\Entity
15
+ * @ORM\Table(name="m_group")
16
+ */
17
+class Group
18
+{
19
+  
20
+  /**
21
+   * @ORM\Id
22
+   * @ORM\Column(type="integer")
23
+   * @ORM\GeneratedValue(strategy="AUTO")
24
+   * @var type int
25
+   */
26
+  protected $id;
27
+  
28
+  /**
29
+   * Nom du groupe
30
+   * 
31
+   * @ORM\Column(type="string", length=128)
32
+   * @var type string
33
+   */
34
+  protected $name;
35
+  
36
+  /**
37
+   * Si open est a vrai, cela traduit que les followers peuvent 
38
+   * diffuser leur element en tant qu'élément de ce groupe.
39
+   * 
40
+   * @ORM\Column(type="boolean")
41
+   * @var type string
42
+   */
43
+  protected $open = false;
44
+  
45
+  /**
46
+   * Cet attribut contient les enregistrements FollowGroup lié 
47
+   * a ce Groupe dans le cadre des groupes suivis.
48
+   * 
49
+   * @ORM\OneToMany(targetEntity="FollowGroup", mappedBy="group")
50
+   */
51
+  protected $followers;
52
+  
53
+  /**
54
+   * Propriétaire
55
+   * 
56
+   * @ORM\ManyToOne(targetEntity="Muzich\UserBundle\Entity\User")
57
+   * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
58
+   */
59
+  protected $owner;
60
+
61
+  /**
62
+   * 
63
+   */
64
+  public function __construct()
65
+  {
66
+    $this->followers = new ArrayCollection();
67
+    parent::__construct();
68
+  }
69
+  
70
+  /**
71
+   * Get id
72
+   *
73
+   * @return integer 
74
+   */
75
+  public function getId()
76
+  {
77
+    return $this->id;
78
+  }
79
+
80
+  /**
81
+   * Set name
82
+   *
83
+   * @param string $name
84
+   */
85
+  public function setName($name)
86
+  {
87
+    $this->name = $name;
88
+  }
89
+
90
+  /**
91
+   * Get name
92
+   *
93
+   * @return string 
94
+   */
95
+  public function getName()
96
+  {
97
+    return $this->name;
98
+  }
99
+
100
+  /**
101
+   * Set open
102
+   *
103
+   * @param boolean $open
104
+   */
105
+  public function setOpen($open)
106
+  {
107
+    $this->open = $open;
108
+  }
109
+
110
+  /**
111
+   * Get open
112
+   *
113
+   * @return boolean 
114
+   */
115
+  public function getOpen()
116
+  {
117
+    return $this->open;
118
+  }
119
+
120
+  /**
121
+   * Add followers
122
+   *
123
+   * @param FollowGroup $followers
124
+   */
125
+  public function addFollowGroup(FollowGroup $followers)
126
+  {
127
+    $this->followers[] = $followers;
128
+  }
129
+
130
+  /**
131
+   * Get followers
132
+   *
133
+   * @return Doctrine\Common\Collections\Collection 
134
+   */
135
+  public function getFollowers()
136
+  {
137
+    return $this->followers;
138
+  }
139
+
140
+  /**
141
+   * Set owner
142
+   *
143
+   * @param Muzich\UserBundle\Entity\User $owner
144
+   */
145
+  public function setOwner(Muzich\UserBundle\Entity\User $owner)
146
+  {
147
+      $this->owner = $owner;
148
+  }
149
+
150
+  /**
151
+   * Get owner
152
+   *
153
+   * @return Muzich\UserBundle\Entity\User 
154
+   */
155
+  public function getOwner()
156
+  {
157
+      return $this->owner;
158
+  }
159
+}

+ 0 - 6
src/Muzich/UserBundle/Entity/FollowUser.php Ver fichero

@@ -38,12 +38,6 @@ class FollowUser
38 38
    */
39 39
   protected $followed;
40 40
   
41
-  public function __construct()
42
-  {
43
-    $this->follower = new ArrayCollection();
44
-    $this->followed = new ArrayCollection();
45
-  }
46
-  
47 41
   /**
48 42
    * Get id
49 43
    *

+ 67 - 7
src/Muzich/UserBundle/Entity/User.php Ver fichero

@@ -58,6 +58,21 @@ class User extends BaseUser
58 58
    * @ORM\OneToMany(targetEntity="FollowUser", mappedBy="followed")
59 59
    */
60 60
   protected $followers_users;
61
+  
62
+  /**
63
+   * Cet attribut contient les enregistrements FollowGroup lié 
64
+   * a cet utilisateur dans le cadre des groupes suivis.
65
+   * 
66
+   * @ORM\OneToMany(targetEntity="Muzich\CoreBundle\Entity\FollowGroup", mappedBy="user")
67
+   */
68
+  protected $followed_groups;
69
+  
70
+  /**
71
+   * Liste des Groupes appartenant a cet utilisateur.
72
+   * 
73
+   * @ORM\OneToMany(targetEntity="Muzich\CoreBundle\Entity\Group", mappedBy="owner")
74
+   */
75
+  protected $groups_owned;
61 76
 
62 77
   /**
63 78
    * 
@@ -66,6 +81,11 @@ class User extends BaseUser
66 81
   {
67 82
     $this->tags_favorites = new ArrayCollection();
68 83
     $this->elements = new ArrayCollection();
84
+    $this->elements_favorites = new ArrayCollection();
85
+    $this->followeds_users = new ArrayCollection();
86
+    $this->followers_users = new ArrayCollection();
87
+    $this->followed_groups = new ArrayCollection();
88
+    $this->groups = new ArrayCollection();
69 89
     parent::__construct();
70 90
   }
71 91
 
@@ -106,7 +126,7 @@ class User extends BaseUser
106 126
    */
107 127
   public function addUsersElementsFavorites(Muzich\CoreBundle\Entity\UsersElementsFavorites $elementsFavorites)
108 128
   {
109
-      $this->elements_favorites[] = $elementsFavorites;
129
+    $this->elements_favorites[] = $elementsFavorites;
110 130
   }
111 131
 
112 132
   /**
@@ -116,7 +136,7 @@ class User extends BaseUser
116 136
    */
117 137
   public function getElementsFavorites()
118 138
   {
119
-      return $this->elements_favorites;
139
+    return $this->elements_favorites;
120 140
   }
121 141
 
122 142
   /**
@@ -126,7 +146,7 @@ class User extends BaseUser
126 146
    */
127 147
   public function addElement(Muzich\CoreBundle\Entity\Element $elements)
128 148
   {
129
-      $this->elements[] = $elements;
149
+    $this->elements[] = $elements;
130 150
   }
131 151
 
132 152
   /**
@@ -136,7 +156,7 @@ class User extends BaseUser
136 156
    */
137 157
   public function getElements()
138 158
   {
139
-      return $this->elements;
159
+    return $this->elements;
140 160
   }
141 161
 
142 162
   /**
@@ -146,7 +166,7 @@ class User extends BaseUser
146 166
    */
147 167
   public function addFollowUser(FollowUser $followedsUsers)
148 168
   {
149
-      $this->followeds_users[] = $followedsUsers;
169
+    $this->followeds_users[] = $followedsUsers;
150 170
   }
151 171
 
152 172
   /**
@@ -156,7 +176,7 @@ class User extends BaseUser
156 176
    */
157 177
   public function getFollowedsUsers()
158 178
   {
159
-      return $this->followeds_users;
179
+    return $this->followeds_users;
160 180
   }
161 181
 
162 182
   /**
@@ -166,6 +186,46 @@ class User extends BaseUser
166 186
    */
167 187
   public function getFollowersUsers()
168 188
   {
169
-      return $this->followers_users;
189
+    return $this->followers_users;
190
+  }
191
+
192
+  /**
193
+   * Add followed_groups
194
+   *
195
+   * @param Muzich\CoreBundle\Entity\FollowGroup $followedGroups
196
+   */
197
+  public function addFollowGroup(Muzich\CoreBundle\Entity\FollowGroup $followedGroups)
198
+  {
199
+    $this->followed_groups[] = $followedGroups;
200
+  }
201
+
202
+  /**
203
+   * Get followed_groups
204
+   *
205
+   * @return Doctrine\Common\Collections\Collection 
206
+   */
207
+  public function getFollowedGroups()
208
+  {
209
+    return $this->followed_groups;
210
+  }
211
+
212
+  /**
213
+   * Add groups
214
+   *
215
+   * @param Muzich\CoreBundle\Entity\Group $groups
216
+   */
217
+  public function addGroupOwned(Muzich\CoreBundle\Entity\Group $groups)
218
+  {
219
+    $this->groups[] = $groups;
220
+  }
221
+
222
+  /**
223
+   * Get groups
224
+   *
225
+   * @return Doctrine\Common\Collections\Collection 
226
+   */
227
+  public function getGroupsOnwed()
228
+  {
229
+    return $this->groups;
170 230
   }
171 231
 }