Browse Source

Use core app.user instead of forwarding the user object by hand

Jordi Boggiano 13 years ago
parent
commit
66ae44c4fd

+ 2 - 2
src/Packagist/WebBundle/Controller/WebController.php

@@ -43,7 +43,7 @@ class WebController extends Controller
             ->getRepository('Packagist\WebBundle\Entity\Package')
             ->findAll();
 
-        return array('packages' => $packages, 'page' => 'home', 'user' => $this->getUser());
+        return array('packages' => $packages, 'page' => 'home');
     }
 
     /**
@@ -74,7 +74,7 @@ class WebController extends Controller
             }
         }
 
-        return array('form' => $form->createView(), 'page' => 'submit', 'user' => $this->getUser());
+        return array('form' => $form->createView(), 'page' => 'submit');
     }
 
     /**

+ 2 - 2
src/Packagist/WebBundle/Resources/views/layout.html.twig

@@ -37,8 +37,8 @@
     <body>
         <div class="container">
             <div>
-                {% if user.username is defined %}
-                    {{ user.username }} | <a href="{{ path('fos_user_security_logout') }}">logout</a>
+                {% if app.user %}
+                    {{ app.user.username }} | <a href="{{ path('fos_user_security_logout') }}">logout</a>
                 {% else %}
                     <a href="{{ path('fos_user_security_login') }}">login</a> | <a href="{{ path('fos_user_registration_register') }}">register</a>
                 {% endif %}