require actual password for change + insert link in menu

This commit is contained in:
2018-08-16 13:41:32 +02:00
parent af803cc87d
commit 5b1ba71a8a
9 changed files with 169 additions and 36 deletions

View File

@@ -18,6 +18,8 @@
namespace Chill\MainBundle\Routing\MenuBuilder;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
/**
*
@@ -26,17 +28,40 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
*/
class UserMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var TokenStorageInterface
*/
protected $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters)
{
$menu->addChild(
if ($this->tokenStorage->getToken()->getUser() instanceof User) {
$menu
->addChild(
'Change password',
[ 'route' => 'change_my_password']
)
->setExtras([
'order' => 99999999998
]);
}
$menu
->addChild(
'Logout',
[
'route' => 'logout'
])
->setExtras([
'order'=> 99999999999,
'icon' => 'power-off'
]);
->setExtras([
'order'=> 99999999999,
'icon' => 'power-off'
]);
}
public static function getMenuIds(): array