<?php
namespace App\Http\Admin\Menu;
use App\Infrastructure\Menu\Data\Menu;
use App\Infrastructure\Menu\Event\MenuAdminEvent;
use Knp\Menu\ItemInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CollaboratorSubscriber extends Menu implements EventSubscriberInterface
{
/**
* @var ItemInterface
*/
protected $menu;
/**
* Items to add in menu
*
* @var array
*/
private static $items = array(
[
'Collaborateurs',
[
'route' => 'admin_collaborator_index',
'attributes' => [
'permission' => [
'attribute' => 'ROLE_ADMIN',
'object' => ''
]
]
],
[]
]
);
/**
* @param MenuAdminEvent $event
*/
public function onMenuConfigure(MenuAdminEvent $event)
{
$this->menu = $event->getMenu();
foreach (self::$items as $data) {
$this->addItem($data[0], $data[1], $data[2]);
}
}
public static function getSubscribedEvents()
{
return [
MenuAdminEvent::CONFIGURE => ['onMenuConfigure',95],
];
}
}