title: Symfony2: How to get user Object inside controller when using FOSUserBundle?
body: <p>I'm using FOSUserBundle to authenticate my users.</p>
  
  <p>I'm trying to get the user object inside the Controller to register a trip where I should add the user object to this Trip before save.</p>
  
  <p>I did not found how to do that because next method where I found it in symfony doc:</p>
  
  <pre><code>$user = $this-&gt;container-&gt;get('security.context')-&gt;getToken()-&gt;getUser();
  </code></pre>
  
  <p>renders the username as string, but I need the whole object.</p>
  
  <p>Currently, I use this method, but it's not working properly.</p>
  
  <pre><code>$username = $this-&gt;container-&gt;get('security.context')-&gt;getToken()-&gt;getUser();
  $em = $this-&gt;container-&gt;get('doctrine')-&gt;getEntityManager();
  $user = $em-&gt;getRepository('SiteUtilisateurBundle:Utilisateur')-&gt;find($username);
  </code></pre>
  
  <p>How can I correctly do this?</p>