counter = $counter; $this->tokenStorage = $tokenStorage; $this->translator = $translator; $this->authorizationChecker = $authorizationChecker; } public function buildMenu($menuId, MenuItem $menu, array $parameters) { if (false === $this->authorizationChecker->isGranted(TaskVoter::SHOW)) { return; } $user = $this->tokenStorage->getToken()->getUser(); $ended = $this->counter->countNotificationEnded($user); $warning = $this->counter->countNotificationWarning($user); if (0 < $ended) { $this->addItemInMenu( $menu, '%number% tasks over deadline', $ended, -15, ['new', 'in_progress'], ['alert'] ); } if (0 < $warning) { $this->addItemInMenu( $menu, '%number% tasks near deadline', $warning, -14, ['new', 'in_progress'], ['warning'] ); } $menu->addChild('My tasks', [ 'route' => 'chill_task_singletask_my_tasks', ]) ->setExtras([ 'order' => -10, 'icon' => 'tasks', ]); } public static function getMenuIds(): array { return ['user']; } protected function addItemInMenu(MenuItem $menu, $message, $number, $order, array $states = [], array $status = []) { if (0 < $number) { $menu->addChild( $this->translator->transChoice($message, $number), [ 'route' => 'chill_task_singletask_my_tasks', 'routeParameters' => [ 'f' => [ 'checkboxes' => [ 'states' => $states, 'status' => $status, ], ], ], ] ) ->setExtras([ 'order' => $order, 'icon' => 'exclamation-triangle', 'entryclass' => 'user_menu__entry--warning-entry', ]); } } }