mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +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 Chill\TaskBundle\Templating\UI\CountNotificationTask;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -42,12 +43,20 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public $tokenStorage;
|
public $tokenStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
public $translator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CountNotificationTask $counter,
|
CountNotificationTask $counter,
|
||||||
TokenStorageInterface $tokenStorage
|
TokenStorageInterface $tokenStorage,
|
||||||
|
TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
$this->counter = $counter;
|
$this->counter = $counter;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
@ -57,21 +66,29 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
if ($this->counter->countNotification($this->tokenStorage->getToken()
|
$number = $this->counter->countNotification($this->tokenStorage->getToken()
|
||||||
->getUser()) > 0) {
|
->getUser());
|
||||||
$menu->addChild('Task near deadlines', [
|
|
||||||
'route' => 'chill_task_singletask_list',
|
if ($number > 0) {
|
||||||
'routeParameters' => [
|
$menu->addChild(
|
||||||
'user_id' => $this->tokenStorage
|
$this->translator->transChoice('%number% tasks near deadline', $number),
|
||||||
->getToken()
|
[
|
||||||
->getUser()
|
'route' => 'chill_task_singletask_list',
|
||||||
->getId(),
|
'routeParameters' => [
|
||||||
'status' => [
|
'user_id' => $this->tokenStorage
|
||||||
SingleTaskRepository::DATE_STATUS_WARNING,
|
->getToken()
|
||||||
SingleTaskRepository::DATE_STATUS_ENDED
|
->getUser()
|
||||||
]
|
->getId(),
|
||||||
|
'status' => [
|
||||||
|
SingleTaskRepository::DATE_STATUS_WARNING,
|
||||||
|
SingleTaskRepository::DATE_STATUS_ENDED
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]);
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order'=> -15,
|
||||||
|
'icon' => 'exclamation-triangle'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,6 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
||||||
$counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask'
|
$counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask'
|
||||||
|
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'chill.menu_builder' }
|
- { name: 'chill.menu_builder' }
|
||||||
|
@ -72,3 +72,4 @@ cancel: annuler
|
|||||||
'The task has been updated': 'La tâche a été mise à jour'
|
'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 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"
|
'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