mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
set order in user menu + translations
This commit is contained in:
parent
f19c9e85dc
commit
583c10128d
@ -22,6 +22,7 @@ use Knp\Menu\MenuItem;
|
||||
use Chill\TaskBundle\Templating\UI\CountNotificationTask;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -42,12 +43,20 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
*/
|
||||
public $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
public $translator;
|
||||
|
||||
public function __construct(
|
||||
CountNotificationTask $counter,
|
||||
TokenStorageInterface $tokenStorage
|
||||
TokenStorageInterface $tokenStorage,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->counter = $counter;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
@ -57,21 +66,29 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
if ($this->counter->countNotification($this->tokenStorage->getToken()
|
||||
->getUser()) > 0) {
|
||||
$menu->addChild('Task near deadlines', [
|
||||
'route' => 'chill_task_singletask_list',
|
||||
'routeParameters' => [
|
||||
'user_id' => $this->tokenStorage
|
||||
->getToken()
|
||||
->getUser()
|
||||
->getId(),
|
||||
'status' => [
|
||||
SingleTaskRepository::DATE_STATUS_WARNING,
|
||||
SingleTaskRepository::DATE_STATUS_ENDED
|
||||
]
|
||||
$number = $this->counter->countNotification($this->tokenStorage->getToken()
|
||||
->getUser());
|
||||
|
||||
if ($number > 0) {
|
||||
$menu->addChild(
|
||||
$this->translator->transChoice('%number% tasks near deadline', $number),
|
||||
[
|
||||
'route' => 'chill_task_singletask_list',
|
||||
'routeParameters' => [
|
||||
'user_id' => $this->tokenStorage
|
||||
->getToken()
|
||||
->getUser()
|
||||
->getId(),
|
||||
'status' => [
|
||||
SingleTaskRepository::DATE_STATUS_WARNING,
|
||||
SingleTaskRepository::DATE_STATUS_ENDED
|
||||
]
|
||||
]
|
||||
]);
|
||||
])
|
||||
->setExtras([
|
||||
'order'=> -15,
|
||||
'icon' => 'exclamation-triangle'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,6 @@ services:
|
||||
arguments:
|
||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
||||
$counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask'
|
||||
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||
tags:
|
||||
- { name: 'chill.menu_builder' }
|
||||
|
@ -72,3 +72,4 @@ cancel: annuler
|
||||
'The task has been updated': 'La tâche a été mise à jour'
|
||||
'The transition is successfully applied': 'La transition a bien été effectuée'
|
||||
'The transition could not be applied': "La transition n'a pas pu être appliquée"
|
||||
'%number% tasks near deadline': '{0} Aucune tâche à échance|{1} Une tâche à échéance | ]1,Inf[ %count% tâches à échéance'
|
Loading…
x
Reference in New Issue
Block a user