mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,42 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\TaskBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
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;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||
use Chill\TaskBundle\Templating\UI\CountNotificationTask;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
public $authorizationChecker;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var CountNotificationTask
|
||||
*/
|
||||
public $counter;
|
||||
@@ -47,17 +35,10 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
public $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
public $translator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
public $authorizationChecker;
|
||||
|
||||
public function __construct(
|
||||
CountNotificationTask $counter,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
@@ -70,14 +51,9 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
$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)) {
|
||||
if (false === $this->authorizationChecker->isGranted(TaskVoter::SHOW)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +61,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
$ended = $this->counter->countNotificationEnded($user);
|
||||
$warning = $this->counter->countNotificationWarning($user);
|
||||
|
||||
if ($ended > 0) {
|
||||
if (0 < $ended) {
|
||||
$this->addItemInMenu(
|
||||
$menu,
|
||||
'%number% tasks over deadline',
|
||||
@@ -96,7 +72,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
);
|
||||
}
|
||||
|
||||
if ($warning > 0) {
|
||||
if (0 < $warning) {
|
||||
$this->addItemInMenu(
|
||||
$menu,
|
||||
'%number% tasks near deadline',
|
||||
@@ -107,19 +83,23 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
);
|
||||
}
|
||||
|
||||
$menu->addChild("My tasks", [
|
||||
'route' => 'chill_task_singletask_my_tasks'
|
||||
])
|
||||
$menu->addChild('My tasks', [
|
||||
'route' => 'chill_task_singletask_my_tasks',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => -10,
|
||||
'icon' => 'tasks'
|
||||
'icon' => 'tasks',
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['user'];
|
||||
}
|
||||
|
||||
protected function addItemInMenu(MenuItem $menu, $message, $number, $order, array $states = [], array $status = [])
|
||||
{
|
||||
if ($number > 0) {
|
||||
if (0 < $number) {
|
||||
$menu->addChild(
|
||||
$this->translator->transChoice($message, $number),
|
||||
[
|
||||
@@ -128,15 +108,16 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
'f' => [
|
||||
'checkboxes' => [
|
||||
'states' => $states,
|
||||
'status' => $status
|
||||
]
|
||||
]
|
||||
'status' => $status,
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
])
|
||||
)
|
||||
->setExtras([
|
||||
'order'=> $order,
|
||||
'order' => $order,
|
||||
'icon' => 'exclamation-triangle',
|
||||
'entryclass' => 'user_menu__entry--warning-entry'
|
||||
'entryclass' => 'user_menu__entry--warning-entry',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user