Menu/MenuBuilder.php
public function createUserMenu()
    {
        $menu = $this->factory->createItem('root');

        if ($this->accountEnabled) {
            if (null !== $token = $this->tokenStorage->getToken()) {
                if ($this->authorization->isGranted('IS_AUTHENTICATED_FULLY') || $this->authorization->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                    /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
                    $user = $token->getUser();
                    $item = $menu->addChild($user->getEmail(), ['uri' => '#']);
                    $item->addChild('ekyna_user.account.menu.my_profile', ['route' => 'fos_user_profile_show']);
                    if ($this->authorization->isGranted('ROLE_ADMIN')) {
                        $item->addChild('ekyna_user.account.menu.backend', ['route' => 'ekyna_admin']);
                    }
                    $item->addChild('ekyna_user.account.menu.logout', ['route' => 'fos_user_security_logout']);
                    return $menu;
                }
            }
            $menu->addChild('ekyna_user.account.menu.login', ['route' => 'fos_user_security_login']);
        }

        return $menu;
    }
public function createUserMenu()
    {
        $menu = $this->factory->createItem('root');

        if ($this->accountEnabled) {
            if (null !== $token = $this->tokenStorage->getToken()) {
                if ($this->authorization->isGranted('IS_AUTHENTICATED_FULLY') || $this->authorization->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                    /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
                    $user = $token->getUser();
                    $item = $menu->addChild($user->getEmail(), ['uri' => '#']);
                    $item->addChild('ekyna_user.account.menu.my_profile', ['route' => 'fos_user_profile_show']);
                    if ($this->authorization->isGranted('ROLE_ADMIN')) {
                        $item->addChild('ekyna_user.account.menu.backend', ['route' => 'ekyna_admin']);
                    }
                    $item->addChild('ekyna_user.account.menu.logout', ['route' => 'fos_user_security_logout']);
                    return $menu;
                }
            }
            $menu->addChild('ekyna_user.account.menu.login', ['route' => 'fos_user_security_login']);
        }

        return $menu;
    }
public function createUserMenu ( ) { $ menu = $ this -> factory -> createItem ( 'root' ) ; if ( $ this -> accountEnabled ) { if ( null !== $ token = $ this -> tokenStorage -> getToken ( ) ) { if ( $ this -> authorization -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) || $ this -> authorization -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */ $ user = $ token -> getUser ( ) ; $ item = $ menu -> addChild ( $ user -> getEmail ( ) , [ 'uri' => '#' ] ) ; $ item -> addChild ( 'ekyna_user.account.menu.my_profile' , [ 'route' => 'fos_user_profile_show' ] ) ; if ( $ this -> authorization -> isGranted ( 'ROLE_ADMIN' ) ) { $ item -> addChild ( 'ekyna_user.account.menu.backend' , [ 'route' => 'ekyna_admin' ] ) ; } $ item -> addChild ( 'ekyna_user.account.menu.logout' , [ 'route' => 'fos_user_security_logout' ] ) ; return $ menu ; } } $ menu -> addChild ( 'ekyna_user.account.menu.login' , [ 'route' => 'fos_user_security_login' ] ) ; } return $ menu ; }
Creates the user menu.

@return \Knp\Menu\ItemInterface
Creates the user menu .