added API for handling work contract times (#4016)
This commit is contained in:
@@ -9,15 +9,16 @@
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Event\ConfigureMainMenuEvent;
|
||||
use App\Utils\MenuItemModel;
|
||||
use KevinPapst\TablerBundle\Helper\ContextHelper;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
final class MenuSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private AuthorizationCheckerInterface $security, private ContextHelper $helper)
|
||||
public function __construct(private Security $security, private ContextHelper $helper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,6 +46,8 @@ final class MenuSubscriber implements EventSubscriberInterface
|
||||
|
||||
// main menu
|
||||
$menu = $event->getMenu();
|
||||
/** @var User $user */
|
||||
$user = $auth->getUser();
|
||||
|
||||
$menu->addChild(new MenuItemModel('dashboard', 'dashboard.title', 'dashboard', [], 'dashboard'));
|
||||
$menu->addChild(new MenuItemModel('favorites', 'favorite_routes', null, [], 'bookmarked'));
|
||||
@@ -87,6 +90,15 @@ final class MenuSubscriber implements EventSubscriberInterface
|
||||
$menu->addChild($times);
|
||||
}
|
||||
|
||||
$contract = new MenuItemModel('contract', 'work_contract', null, [], 'contract');
|
||||
if ($user->hasContractSettings() || $auth->isGranted('contract_other_profile')) {
|
||||
$contract->addChild(new MenuItemModel('contract_status', 'work_times', 'user_contract', [], 'work_times'));
|
||||
}
|
||||
|
||||
if ($contract->hasChildren()) {
|
||||
$menu->addChild($contract);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_reporting')) {
|
||||
$reporting = new MenuItemModel('reporting', 'menu.reporting', 'reporting', [], 'reporting');
|
||||
$reporting->setChildRoutes(['report_user_week', 'report_user_month', 'report_weekly_users', 'report_monthly_users', 'report_project_view']);
|
||||
|
||||
Reference in New Issue
Block a user