|
@@ -3,18 +3,24 @@
|
|
|
namespace Packagist\WebBundle\Menu;
|
|
|
|
|
|
use Knp\Menu\FactoryInterface;
|
|
|
-use Symfony\Component\HttpFoundation\Request;
|
|
|
+use Symfony\Component\Security\Core\SecurityContextInterface;
|
|
|
|
|
|
class MenuBuilder
|
|
|
{
|
|
|
private $factory;
|
|
|
+ private $username;
|
|
|
|
|
|
/**
|
|
|
* @param FactoryInterface $factory
|
|
|
+ * @param SecurityContextInterface $securityContext
|
|
|
*/
|
|
|
- public function __construct(FactoryInterface $factory)
|
|
|
+ public function __construct(FactoryInterface $factory, SecurityContextInterface $securityContext)
|
|
|
{
|
|
|
$this->factory = $factory;
|
|
|
+
|
|
|
+ if ($securityContext->getToken() && $securityContext->getToken()->getUsername()) {
|
|
|
+ $this->username = $securityContext->getToken()->getUsername();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function createUserMenu()
|
|
@@ -25,8 +31,8 @@ class MenuBuilder
|
|
|
$menu->addChild('Profile', array('label' => '<span class="icon-vcard"></span>Profile', 'route' => 'fos_user_profile_show', 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('Settings', array('label' => '<span class="icon-tools"></span>Settings', 'route' => 'fos_user_profile_edit', 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('Change password', array('label' => '<span class="icon-key"></span>Change password', 'route' => 'fos_user_change_password', 'extras' => array('safe_label' => true)));
|
|
|
- $menu->addChild('My packages', array('label' => '<span class="icon-box"></span>My packages', 'route' => 'user_packages', 'routeParameters' => array('name' => 'stloyd'), 'extras' => array('safe_label' => true)));
|
|
|
- $menu->addChild('My favorites', array('label' => '<span class="icon-leaf"></span>My favorites', 'route' => 'user_favorites', 'routeParameters' => array('name' => 'stloyd'), 'extras' => array('safe_label' => true)));
|
|
|
+ $menu->addChild('My packages', array('label' => '<span class="icon-box"></span>My packages', 'route' => 'user_packages', 'routeParameters' => array('name' => $this->username), 'extras' => array('safe_label' => true)));
|
|
|
+ $menu->addChild('My favorites', array('label' => '<span class="icon-leaf"></span>My favorites', 'route' => 'user_favorites', 'routeParameters' => array('name' => $this->username), 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('hr', array('label' => '<hr>', 'labelAttributes' => array('class' => 'normal'), 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('Logout', array('label' => '<span class="icon-off"></span>Logout', 'route' => 'logout', 'extras' => array('safe_label' => true)));
|
|
|
|
|
@@ -41,8 +47,8 @@ class MenuBuilder
|
|
|
$menu->addChild('Profile', array('label' => '<span class="icon-vcard"></span>Profile', 'route' => 'fos_user_profile_show', 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('Edit your information', array('label' => '<span class="icon-tools"></span>Edit your information', 'route' => 'fos_user_profile_edit', 'extras' => array('safe_label' => true)));
|
|
|
$menu->addChild('Change password', array('label' => '<span class="icon-key"></span>Change password', 'route' => 'fos_user_change_password', 'extras' => array('safe_label' => true)));
|
|
|
- $menu->addChild('View your packages', array('label' => '<span class="icon-box"></span>View your packages', 'route' => 'user_packages', 'routeParameters' => array('name' => 'stloyd'), 'extras' => array('safe_label' => true)));
|
|
|
- $menu->addChild('View your favorites', array('label' => '<span class="icon-leaf"></span>View your favorites', 'route' => 'user_favorites', 'routeParameters' => array('name' => 'stloyd'), 'extras' => array('safe_label' => true)));
|
|
|
+ $menu->addChild('View your packages', array('label' => '<span class="icon-box"></span>View your packages', 'route' => 'user_packages', 'routeParameters' => array('name' => $this->username), 'extras' => array('safe_label' => true)));
|
|
|
+ $menu->addChild('View your favorites', array('label' => '<span class="icon-leaf"></span>View your favorites', 'route' => 'user_favorites', 'routeParameters' => array('name' => $this->username), 'extras' => array('safe_label' => true)));
|
|
|
|
|
|
return $menu;
|
|
|
}
|