mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-27 05:54:02 +01:00
42 lines
954 B
PHP
42 lines
954 B
PHP
|
<?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;
|
||
|
}
|
||
|
}
|