mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Added draft for user menu based on https://gist.github.com/lsv/4d8044d21819f28f0dde52a3fb8211a0
This commit is contained in:
42
application/src/Menu/Menu.php
Normal file
42
application/src/Menu/Menu.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// src/Menu/Menu.php
|
||||
|
||||
namespace App\Menu;
|
||||
|
||||
use App\Event\Menu\Topbar\UserMenuEvent;
|
||||
use Knp\Menu\FactoryInterface;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class Menu
|
||||
{
|
||||
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
* @var FactoryInterface
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
public function __construct(FactoryInterface $factory, EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->factory = $factory;
|
||||
}
|
||||
|
||||
public function userTopbar(RequestStack $request): ItemInterface
|
||||
{
|
||||
$menu = $this->factory->createItem('root');
|
||||
|
||||
$this->dispatcher->dispatch(
|
||||
UserMenuEvent::EVENT,
|
||||
new UserMenuEvent($this->factory, $menu, $request)
|
||||
);
|
||||
|
||||
return $menu;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user