notificationByUserCounter = $notificationByUserCounter; $this->security = $security; $this->translator = $translator; } public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters) { $user = $this->security->getUser(); if ($user instanceof User) { if (null !== $user->getCurrentLocation()) { $locationTextMenu = $user->getCurrentLocation()->getName(); } else { $locationTextMenu = 'Set a location'; } $menu ->addChild( $locationTextMenu, ['route' => 'chill_main_user_currentlocation_edit'] ) ->setExtras([ 'order' => -9999999, 'icon' => 'map-marker', ]); $nbNotifications = $this->notificationByUserCounter->countUnreadByUser($user); $menu ->addChild( $this->translator->trans('notification.My notifications with counter', ['nb' => $nbNotifications]), ['route' => 'chill_main_notification_my'] ) ->setExtras([ 'order' => 600, 'icon' => 'envelope', 'counter' => $nbNotifications, ]); $menu ->addChild( $this->translator->trans('workflow.My workflows'), ['route' => 'chill_main_workflow_list_dest'] ) ->setExtras([ 'order' => 700, ]); $menu ->addChild( 'Change password', ['route' => 'change_my_password'] ) ->setExtras([ 'order' => 99999999998, ]); } $menu ->addChild( 'Logout', [ 'route' => 'logout', ] ) ->setExtras([ 'order' => 99999999999, 'icon' => 'power-off', ]); } public static function getMenuIds(): array { return ['user']; } }