mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized user menu
This commit is contained in:
parent
e31386b908
commit
777b4aee61
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace App\Subscriber;
|
||||
|
||||
use App\Event\Menu\Topbar\UserMenuEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@ -29,67 +30,52 @@ class UserMenuSubscriber implements EventSubscriberInterface
|
||||
public function onUserMenuConfigure(UserMenuEvent $event): void
|
||||
{
|
||||
$menu = $event->getItem();
|
||||
$menu->addChild(
|
||||
'start',
|
||||
[
|
||||
'route' => 'homepage',
|
||||
'attributes' => [
|
||||
'icon' => 'fab fa-font-awesome-flag',
|
||||
],
|
||||
$menu->addChild('start', [
|
||||
'route' => 'homepage',
|
||||
'attributes' => [
|
||||
'icon' => 'fab fa-font-awesome-flag'
|
||||
]
|
||||
);
|
||||
|
||||
$menu->addChild(
|
||||
'imprint',
|
||||
[
|
||||
'route'=>'imprint',
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-address-card',
|
||||
],
|
||||
]);
|
||||
|
||||
$menu->addChild('imprint', [
|
||||
'route' => 'imprint',
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-address-card'
|
||||
]
|
||||
);
|
||||
|
||||
$dropdown = $menu->addChild(
|
||||
'user',
|
||||
[
|
||||
'attributes' => [
|
||||
'dropdown' => true,
|
||||
'icon' => 'fas fa-user',
|
||||
],
|
||||
]);
|
||||
|
||||
$dropdown = $menu->addChild('user', [
|
||||
'attributes' => [
|
||||
'dropdown' => true,
|
||||
'icon' => 'fas fa-user'
|
||||
]
|
||||
);
|
||||
|
||||
$dropdown->addChild(
|
||||
'login',
|
||||
[
|
||||
'route' => 'login',
|
||||
'attributes' => [
|
||||
'divider_append' => true,
|
||||
'icon' => 'fas fa-sign-in-alt',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$dropdown->addChild(
|
||||
'logout',
|
||||
[
|
||||
]);
|
||||
/**
|
||||
* @todo replace the following check trough fos bundle
|
||||
*/
|
||||
if ($this->tokenStorage->getToken()->getRoles()) {
|
||||
$dropdown->addChild('logout', [
|
||||
'route' => 'logout',
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-sign-out-alt',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$dropdown->addChild(
|
||||
'register',
|
||||
[
|
||||
'route' => 'user_register',
|
||||
'divider_append' => true,
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
$dropdown->addChild('login', [
|
||||
'route' => 'login',
|
||||
'attributes' => [
|
||||
'divider_prepend' => true,
|
||||
'icon' => 'fas fa-file-signature',
|
||||
],
|
||||
'divider_append' => true,
|
||||
'icon' => 'fas fa-sign-in-alt'
|
||||
]
|
||||
]);
|
||||
}
|
||||
$dropdown->addChild('register', [
|
||||
'route' => 'user_register',
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-file-signature'
|
||||
]
|
||||
);
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
|
Loading…
Reference in New Issue
Block a user