mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 06:14:59 +00:00
fixes for settign a localisation
This commit is contained in:
@@ -20,35 +20,37 @@ namespace Chill\MainBundle\Routing\MenuBuilder;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
public function __construct(TokenStorageInterface $tokenStorage)
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters)
|
||||
{
|
||||
if ($this->tokenStorage->getToken()->getUser() instanceof User) {
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if ($user instanceof User) {
|
||||
|
||||
if (null !== $user->getCurrentLocation()) {
|
||||
$locationTextMenu = $user->getCurrentLocation()->getName();
|
||||
} else {
|
||||
$locationTextMenu = 'Set a location';
|
||||
}
|
||||
|
||||
$menu
|
||||
->addChild(
|
||||
'Change location',
|
||||
$locationTextMenu,
|
||||
['route' => 'chill_main_user_currentlocation_edit']
|
||||
)
|
||||
->setExtras([
|
||||
'order' => 99999999997
|
||||
'order' => -9999999,
|
||||
'icon' => 'map-marker'
|
||||
]);
|
||||
$menu
|
||||
->addChild(
|
||||
|
Reference in New Issue
Block a user