mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
fix: SA: Fix "...an unused use..." rule.
Also fix a critical bug in `ListPerson.php`. SA stands for Static Analysis.
This commit is contained in:
@@ -1,26 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\TaskBundle\Security\Authorization;
|
||||
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
|
||||
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||
@@ -41,13 +28,13 @@ use Chill\TaskBundle\Security\Authorization\AuthorizationEvent;
|
||||
|
||||
final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
const CREATE_COURSE = 'CHILL_TASK_TASK_CREATE_FOR_COURSE';
|
||||
const CREATE_PERSON = 'CHILL_TASK_TASK_CREATE_FOR_PERSON';
|
||||
const DELETE = 'CHILL_TASK_TASK_DELETE';
|
||||
const SHOW = 'CHILL_TASK_TASK_SHOW';
|
||||
const UPDATE = 'CHILL_TASK_TASK_UPDATE';
|
||||
public const CREATE_COURSE = 'CHILL_TASK_TASK_CREATE_FOR_COURSE';
|
||||
public const CREATE_PERSON = 'CHILL_TASK_TASK_CREATE_FOR_PERSON';
|
||||
public const DELETE = 'CHILL_TASK_TASK_DELETE';
|
||||
public const SHOW = 'CHILL_TASK_TASK_SHOW';
|
||||
public const UPDATE = 'CHILL_TASK_TASK_UPDATE';
|
||||
|
||||
const ROLES = [
|
||||
public const ROLES = [
|
||||
self::CREATE_COURSE,
|
||||
self::CREATE_PERSON,
|
||||
self::DELETE,
|
||||
@@ -55,33 +42,23 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
|
||||
self::UPDATE,
|
||||
];
|
||||
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
private AccessDecisionManagerInterface $accessDecisionManager;
|
||||
|
||||
protected AccessDecisionManagerInterface $accessDecisionManager;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
protected EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
protected CenterResolverDispatcher $centerResolverDispatcher;
|
||||
|
||||
protected VoterHelperInterface $voter;
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
private VoterHelperInterface $voter;
|
||||
|
||||
public function __construct(
|
||||
VoterHelperFactoryInterface $voterHelperFactory,
|
||||
AccessDecisionManagerInterface $accessDecisionManager,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
LoggerInterface $logger,
|
||||
CenterResolverDispatcher $centerResolverDispatcher,
|
||||
VoterHelperFactoryInterface $voterFactory
|
||||
) {
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->logger = $logger;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
|
||||
$this->voter = $voterFactory
|
||||
->generate(AbstractTask::class)
|
||||
@@ -89,8 +66,7 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
|
||||
->addCheckFor(Person::class, [self::SHOW, self::CREATE_PERSON])
|
||||
->addCheckFor(AccompanyingPeriod::class, [self::SHOW, self::CREATE_COURSE])
|
||||
->addCheckFor(null, [self::SHOW])
|
||||
->build()
|
||||
;
|
||||
->build();
|
||||
}
|
||||
|
||||
public function supports($attribute, $subject)
|
||||
@@ -98,13 +74,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
|
||||
return $this->voter->supports($attribute, $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param AbstractTask $subject
|
||||
* @param TokenInterface $token
|
||||
* @return boolean
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
$this->logger->debug(sprintf("Voting from %s class", self::class));
|
||||
@@ -118,7 +87,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
|
||||
$this->eventDispatcher->dispatch(AuthorizationEvent::VOTE, $event);
|
||||
|
||||
if ($event->hasVote()) {
|
||||
|
||||
$this->logger->debug("The TaskVoter is overriding by "
|
||||
.AuthorizationEvent::VOTE, [
|
||||
'vote' => $event->getVote(),
|
||||
@@ -167,5 +135,4 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user