mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles
This commit is contained in:
commit
801e897a38
@ -28,36 +28,36 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var CountNotificationTask
|
||||
*/
|
||||
public $counter;
|
||||
|
||||
|
||||
/*
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
public $tokenStorage;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
public $translator;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
public $authorizationChecker;
|
||||
|
||||
|
||||
public function __construct(
|
||||
CountNotificationTask $counter,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
@ -69,44 +69,44 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
$this->translator = $translator;
|
||||
$this->authorizationChecker = $authorizationChecker;
|
||||
}
|
||||
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return [ 'user' ];
|
||||
}
|
||||
|
||||
|
||||
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 ($ended > 0) {
|
||||
$this->addItemInMenu(
|
||||
$menu,
|
||||
$user,
|
||||
'%number% tasks over deadline',
|
||||
$menu,
|
||||
$user,
|
||||
'%number% tasks over deadline',
|
||||
'My tasks over deadline',
|
||||
SingleTaskRepository::DATE_STATUS_ENDED,
|
||||
$ended,
|
||||
$ended,
|
||||
-15);
|
||||
}
|
||||
|
||||
|
||||
if ($warning > 0) {
|
||||
$this->addItemInMenu(
|
||||
$menu,
|
||||
$user,
|
||||
'%number% tasks near deadline',
|
||||
'My tasks near deadline',
|
||||
$menu,
|
||||
$user,
|
||||
'%number% tasks near deadline',
|
||||
'My tasks near deadline',
|
||||
SingleTaskRepository::DATE_STATUS_WARNING,
|
||||
$warning,
|
||||
$warning,
|
||||
-14);
|
||||
}
|
||||
|
||||
|
||||
$menu->addChild("My tasks", [
|
||||
'route' => 'chill_task_single_my_tasks'
|
||||
])
|
||||
@ -115,6 +115,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
'icon' => 'tasks'
|
||||
]);
|
||||
|
||||
/*
|
||||
$menu->addChild("My aside activities", [
|
||||
'route' => 'chill_crud_aside_activity_index'
|
||||
])
|
||||
@ -122,13 +123,14 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
'order' => -10,
|
||||
'icon' => 'tasks'
|
||||
]);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
|
||||
{
|
||||
if ($number > 0) {
|
||||
$menu->addChild(
|
||||
$this->translator->transChoice($message, $number),
|
||||
$this->translator->transChoice($message, $number),
|
||||
[
|
||||
'route' => 'chill_task_singletask_list',
|
||||
'routeParameters' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user