Browse Source

A la méthode getUser() dans le Controlleur surchargé (plus propre).

bastien 13 years ago
parent
commit
924c9751f4

+ 3 - 3
src/Muzich/CoreBundle/DataFixtures/ORM/LoadElementData.php View File

115
     $this->createElement('jamendo_caio_1', 'All Is Full Of Pain', 
115
     $this->createElement('jamendo_caio_1', 'All Is Full Of Pain', 
116
       'http://soundcloud.com/keytek/all-is-full-of-pain', 
116
       'http://soundcloud.com/keytek/all-is-full-of-pain', 
117
       $this->getArrayOfTag(array('tribe', 'hardtek')),
117
       $this->getArrayOfTag(array('tribe', 'hardtek')),
118
-    $soundclound, $jean);
118
+    $soundclound, $paul);
119
     
119
     
120
     $this->createElement('jamendo_reverb_1', 'RE-FUCK (ReVeRB_FBC) mix.', 
120
     $this->createElement('jamendo_reverb_1', 'RE-FUCK (ReVeRB_FBC) mix.', 
121
       'http://soundcloud.com/reverb-2/re-fuck-reverb_fbc-mix', 
121
       'http://soundcloud.com/reverb-2/re-fuck-reverb_fbc-mix', 
122
       $this->getArrayOfTag(array('tribe')),
122
       $this->getArrayOfTag(array('tribe')),
123
-    $soundclound, $jean);
123
+    $soundclound, $paul);
124
     
124
     
125
     $this->createElement('jamendo_cardio_1', 'CardioT3K - Juggernaut Trap', 
125
     $this->createElement('jamendo_cardio_1', 'CardioT3K - Juggernaut Trap', 
126
       'http://soundcloud.com/cardiot3k/cardiot3k-juggernaut-trap', 
126
       'http://soundcloud.com/cardiot3k/cardiot3k-juggernaut-trap', 
127
       $this->getArrayOfTag(array('tribe')),
127
       $this->getArrayOfTag(array('tribe')),
128
-    $soundclound, $jean);
128
+    $soundclound, $paul);
129
 
129
 
130
     $this->entity_manager->flush();
130
     $this->entity_manager->flush();
131
   }
131
   }

+ 10 - 0
src/Muzich/CoreBundle/lib/Controller.php View File

68
     }
68
     }
69
   }
69
   }
70
   
70
   
71
+  /**
72
+   * Retourne l'objet User.
73
+   * 
74
+   * @return User
75
+   */
76
+  protected function getUser()
77
+  {
78
+    return $this->container->get('security.context')->getToken()->getUser();
79
+  }
80
+  
71
 }
81
 }

+ 1 - 1
src/Muzich/HomeBundle/Controller/HomeController.php View File

17
    */
17
    */
18
   public function indexAction()
18
   public function indexAction()
19
   {        
19
   {        
20
-    $user = $this->container->get('security.context')->getToken()->getUser();
20
+    $user = $this->getUser();
21
        
21
        
22
     $query = $this->getDoctrine()
22
     $query = $this->getDoctrine()
23
       ->getRepository('MuzichCoreBundle:Element')
23
       ->getRepository('MuzichCoreBundle:Element')

+ 1 - 1
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

8
   {% for element in elements %} 
8
   {% for element in elements %} 
9
     <li>
9
     <li>
10
       {{element.name}} ({{element.owner.username}})
10
       {{element.name}} ({{element.owner.username}})
11
-        
11
+        <a href="{{element.url}}" target="_blank">link</a>
12
         <ul>
12
         <ul>
13
           {% for tag in element.tags %} 
13
           {% for tag in element.tags %} 
14
             <li>
14
             <li>