feat: add a Mein Account group to the main menu and lock the page while the drawer is open
This commit is contained in:
1 parent
4530d2434b
commit
8a02b28d00
6 files changed
+164
-24
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Menu;
|
||||
|
||||
use App\Entity\User;
|
||||
use Knp\Menu\FactoryInterface;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -31,17 +32,36 @@ class MenuBuilder extends AbstractMenuBuilder
|
||||
|
||||
public function createMainMenu(array $options): ItemInterface
|
||||
{
|
||||
return match ($this->resolveArea()) {
|
||||
$area = $this->resolveArea();
|
||||
$menu = match ($area) {
|
||||
'ROLE_TEAM_ADMIN' => $this->adminMenuBuilder->createMainMenu($options),
|
||||
'ROLE_MANAGER' => $this->managerMenuBuilder->createMainMenu($options),
|
||||
'ROLE_HOUSE_MANAGER' => $this->houseManagerMenuBuilder->createMainMenu($options),
|
||||
'ROLE_TEAMER' => $this->teamerMenuBuilder->createMainMenu($options),
|
||||
default => $this->createRootElement(),
|
||||
};
|
||||
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if ($user instanceof User) {
|
||||
$this->addDivider($menu);
|
||||
|
||||
// A group without uri, so the sidebar renders it collapsible; the teamer menu has its own "Mein Profil".
|
||||
$account = $menu->addChild('account', [
|
||||
'label' => 'Mein Account',
|
||||
'extras' => [
|
||||
'icon' => 'user',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addAccountItems($account, withIcons: false, withProfile: 'ROLE_TEAMER' !== $area);
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* The account menu behind the user's picture in the header: the other areas and logout.
|
||||
* The account menu behind the user's picture in the header: own profile, the other areas and logout.
|
||||
*/
|
||||
public function createUserMenu(array $options): ItemInterface
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user