use pre-defined icons in menu as well (#913)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use App\Event\ConfigureMainMenuEvent;
|
||||
use App\Twig\IconExtension;
|
||||
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
|
||||
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
@@ -18,20 +19,21 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
/**
|
||||
* Menu event subscriber is creating the Kimai default menu structure.
|
||||
*/
|
||||
class MenuSubscriber implements EventSubscriberInterface
|
||||
final class MenuSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
private $security;
|
||||
|
||||
/**
|
||||
* MenuSubscriber constructor.
|
||||
* @param AuthorizationCheckerInterface $security
|
||||
* @var IconExtension
|
||||
*/
|
||||
private $icons;
|
||||
|
||||
public function __construct(AuthorizationCheckerInterface $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->icons = new IconExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,28 +65,28 @@ class MenuSubscriber implements EventSubscriberInterface
|
||||
/**
|
||||
* @param SidebarMenuEvent $menu
|
||||
*/
|
||||
protected function configureMainMenu(SidebarMenuEvent $menu)
|
||||
private function configureMainMenu(SidebarMenuEvent $menu)
|
||||
{
|
||||
$auth = $this->security;
|
||||
|
||||
if ($auth->isGranted('view_own_timesheet')) {
|
||||
$menu->addItem(
|
||||
new MenuItemModel('timesheet', 'menu.timesheet', 'timesheet', [], 'fas fa-clock')
|
||||
new MenuItemModel('timesheet', 'menu.timesheet', 'timesheet', [], $this->getIcon('timesheet'))
|
||||
);
|
||||
$menu->addItem(
|
||||
new MenuItemModel('calendar', 'calendar.title', 'calendar', [], 'far fa-calendar-alt')
|
||||
new MenuItemModel('calendar', 'calendar.title', 'calendar', [], $this->getIcon('calendar'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_invoice')) {
|
||||
$menu->addItem(
|
||||
new MenuItemModel('invoice', 'menu.invoice', 'invoice', [], 'fas fa-file-invoice')
|
||||
new MenuItemModel('invoice', 'menu.invoice', 'invoice', [], $this->getIcon('invoice'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_export')) {
|
||||
$menu->addItem(
|
||||
new MenuItemModel('export', 'menu.export', 'export', [], 'fas fa-file-export')
|
||||
new MenuItemModel('export', 'menu.export', 'export', [], $this->getIcon('export'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -92,31 +94,31 @@ class MenuSubscriber implements EventSubscriberInterface
|
||||
/**
|
||||
* @param MenuItemModel $menu
|
||||
*/
|
||||
protected function configureAdminMenu(MenuItemModel $menu)
|
||||
private function configureAdminMenu(MenuItemModel $menu)
|
||||
{
|
||||
$auth = $this->security;
|
||||
|
||||
if ($auth->isGranted('view_other_timesheet')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet', [], 'fas fa-user-clock')
|
||||
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet', [], $this->getIcon('timesheet-team'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_customer')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('customer_admin', 'menu.admin_customer', 'admin_customer', [], 'fas fa-user-tie')
|
||||
new MenuItemModel('customer_admin', 'menu.admin_customer', 'admin_customer', [], $this->getIcon('customer'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_project')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('project_admin', 'menu.admin_project', 'admin_project', [], 'fas fa-project-diagram')
|
||||
new MenuItemModel('project_admin', 'menu.admin_project', 'admin_project', [], $this->getIcon('project'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_activity')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('activity_admin', 'menu.admin_activity', 'admin_activity', [], 'fas fa-tasks')
|
||||
new MenuItemModel('activity_admin', 'menu.admin_activity', 'admin_activity', [], $this->getIcon('activity'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -130,26 +132,31 @@ class MenuSubscriber implements EventSubscriberInterface
|
||||
/**
|
||||
* @param MenuItemModel $menu
|
||||
*/
|
||||
protected function configureSystemMenu(MenuItemModel $menu)
|
||||
private function configureSystemMenu(MenuItemModel $menu)
|
||||
{
|
||||
$auth = $this->security;
|
||||
|
||||
if ($auth->isGranted('view_user')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('user_admin', 'menu.admin_user', 'admin_user', [], 'fas fa-users')
|
||||
new MenuItemModel('user_admin', 'menu.admin_user', 'admin_user', [], $this->getIcon('user'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('plugins')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('plugins', 'menu.plugin', 'plugins', [], 'fas fa-plug')
|
||||
new MenuItemModel('plugins', 'menu.plugin', 'plugins', [], $this->getIcon('plugin'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('system_configuration')) {
|
||||
$menu->addChild(
|
||||
new MenuItemModel('system_configuration', 'menu.system_configuration', 'system_configuration', [], 'fas fa-cogs')
|
||||
new MenuItemModel('system_configuration', 'menu.system_configuration', 'system_configuration', [], $this->getIcon('configuration'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function getIcon(string $icon)
|
||||
{
|
||||
return $this->icons->icon($icon, $icon);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user