Bläddra i källkod

Récupération et listing des followS

bastien 13 år sedan
förälder
incheckning
ee017378c0

+ 19 - 4
src/Muzich/CoreBundle/Entity/User.php Visa fil

64
    * Cet attribut contient les enregistrements FollowGroup lié 
64
    * Cet attribut contient les enregistrements FollowGroup lié 
65
    * a cet utilisateur dans le cadre des groupes suivis.
65
    * a cet utilisateur dans le cadre des groupes suivis.
66
    * 
66
    * 
67
-   * @ORM\OneToMany(targetEntity="FollowGroup", mappedBy="user")
67
+   * @ORM\OneToMany(targetEntity="FollowGroup", mappedBy="follower")
68
    */
68
    */
69
   protected $followed_groups;
69
   protected $followed_groups;
70
   
70
   
177
    */
177
    */
178
   public function getFollowedsUsers()
178
   public function getFollowedsUsers()
179
   {
179
   {
180
-    return $this->followeds_users;
180
+    $users = array();
181
+    foreach ($this->followeds_users as $follow_user)
182
+    {
183
+      $users[] = $follow_user->getFollowed();
184
+    }
185
+    return $users;
181
   }
186
   }
182
 
187
 
183
   /**
188
   /**
187
    */
192
    */
188
   public function getFollowersUsers()
193
   public function getFollowersUsers()
189
   {
194
   {
190
-    return $this->followers_users;
195
+    $users = array();
196
+    foreach ($this->followers_users as $follow_user)
197
+    {
198
+      $users[] = $follow_user->getFollower();
199
+    }
200
+    return $users;
191
   }
201
   }
192
 
202
 
193
   /**
203
   /**
207
    */
217
    */
208
   public function getFollowedGroups()
218
   public function getFollowedGroups()
209
   {
219
   {
210
-    return $this->followed_groups;
220
+    $groups = array();
221
+    foreach ($this->followed_groups as $follow_group)
222
+    {
223
+      $groups[] = $follow_group->getGroup();
224
+    }
225
+    return $groups;
211
   }
226
   }
212
 
227
 
213
   /**
228
   /**

+ 11 - 1
src/Muzich/MynetworkBundle/Controller/MynetworkController.php Visa fil

15
    */
15
    */
16
   public function indexAction()
16
   public function indexAction()
17
   {
17
   {
18
-    return array();
18
+    $user = $this->getUser();
19
+    
20
+    $followeds_users = $user->getFollowedsUsers();
21
+    $followeds_groups = $user->getFollowedGroups();
22
+    $followers_users = $user->getFollowersUsers();
23
+    
24
+    return array(
25
+      'followeds_users' => $followeds_users,
26
+      'followeds_groups' => $followeds_groups,
27
+      'followers_users' => $followers_users
28
+    );
19
   }
29
   }
20
   
30
   
21
 }
31
 }

+ 34 - 1
src/Muzich/MynetworkBundle/Resources/views/Mynetwork/index.html.twig Visa fil

3
 {% block title %}Mon réseau{% endblock %}
3
 {% block title %}Mon réseau{% endblock %}
4
 
4
 
5
 {% block content %}
5
 {% block content %}
6
-        
6
+  
7
+  {% if followeds_users %}
8
+    <b>Utilisateurs</b>
9
+    <ul>
10
+    {% for user in followeds_users %} 
11
+      <li>
12
+        {{ user.username }}
13
+      </li>
14
+    {% endfor %}
15
+    </ul>
16
+  {% endif %}
17
+  
18
+  {% if followeds_groups %}
19
+    <b>Groupes</b>
20
+    <ul>
21
+    {% for group in followeds_groups %} 
22
+      <li>
23
+        {{ group.name }}
24
+      </li>
25
+    {% endfor %}
26
+    </ul>
27
+  {% endif %}
28
+  
29
+  {% if followers_users %}
30
+    <b>Vous êtes suivis par</b>
31
+    <ul>
32
+    {% for user in followers_users %} 
33
+      <li>
34
+        {{ user.username }}
35
+      </li>
36
+    {% endfor %}
37
+    </ul>
38
+  {% endif %}
39
+
7
 {% endblock %}
40
 {% endblock %}