Browse Source

Utilisation du SearchElement sur les pages showUser et showGroup

bastien 13 years ago
parent
commit
d24b35ddd8

+ 17 - 28
src/Muzich/HomeBundle/Controller/ShowController.php View File

@@ -18,11 +18,15 @@ class ShowController extends Controller
18 18
     $viewed_user = $this->findUserWithSlug($slug);
19 19
     $user = $this->getUser();
20 20
         
21
+    $search_object = $this->createSearchObject(array(
22
+      'user_id'  => $viewed_user->getId()
23
+    ));
24
+    
21 25
     return array(
22
-      'viewed_user' => $viewed_user,
23
-      'elements'    => $this->getShowedEntityElements($viewed_user->getId(), 'User'),
24
-      'following'   => $user->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()),
25
-      'user'        => $user
26
+      'viewed_user'   => $viewed_user,
27
+      'search_object' => $search_object,
28
+      'following'     => $user->isFollowingUserByQuery($this->getDoctrine(), $viewed_user->getId()),
29
+      'user'          => $user
26 30
     );
27 31
   }
28 32
   
@@ -36,32 +40,17 @@ class ShowController extends Controller
36 40
     $group = $this->findGroupWithSlug($slug);
37 41
     $user = $this->getUser();
38 42
         
43
+    $search_object = $this->createSearchObject(array(
44
+      'group_id'  => $group->getId()
45
+    ));
46
+    
39 47
     return array(
40
-      'group'       => $group,
41
-      'his_group'   => ($group->getOwner()->getId() == $user->getId()) ? true : false,
42
-      'elements'    => $this->getShowedEntityElements($group->getId(), 'Group'),
43
-      'following'   => $user->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
44
-      'user'        => $user
48
+      'group'         => $group,
49
+      'his_group'     => ($group->getOwner()->getId() == $user->getId()) ? true : false,
50
+      'search_object' => $search_object,
51
+      'following'     => $user->isFollowingGroupByQuery($this->getDoctrine(), $group->getId()),
52
+      'user'          => $user
45 53
     );
46 54
   }
47 55
   
48
-  /**
49
-   * Refactorisation pour showUserAction et showGroupAction. Récupére les 
50
-   * elements de l'entité demandé.
51
-   *
52
-   * @param Entity $entity
53
-   * @param string $type
54
-   * @return array 
55
-   */
56
-  protected function getShowedEntityElements($entity_id, $type)
57
-  {
58
-    $findBy = 'findBy'.$type;
59
-    return $this->getDoctrine()
60
-      ->getRepository('MuzichCoreBundle:Element')
61
-      ->$findBy($entity_id, 10)
62
-      
63
-      ->execute()
64
-    ;
65
-  }
66
-  
67 56
 }

+ 2 - 2
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

@@ -1,6 +1,6 @@
1 1
 {% extends "MuzichHomeBundle::layout.html.twig" %}
2 2
 
3
-{% block title %}{% endblock %}
3
+{% block title %}{{ group.name }}{% endblock %}
4 4
 
5 5
 {% block content %}
6 6
 
@@ -24,6 +24,6 @@
24 24
     
25 25
   <h2>{{ group.name }}</h2>
26 26
   
27
-  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
27
+  {% render "MuzichCoreBundle:Search:doSearchElements" with { 'search': search_object } %}
28 28
     
29 29
 {% endblock %}

+ 1 - 1
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

@@ -22,6 +22,6 @@
22 22
 
23 23
   <h2>{{ viewed_user.name }}</h2>
24 24
   
25
-  {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
25
+  {% render "MuzichCoreBundle:Search:doSearchElements" with { 'search': search_object } %}
26 26
     
27 27
 {% endblock %}