mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
fix: Strict types interfaces: VoterHelperInterface
, ProvideRoleHierarchyInterface
and ProvideRoleInterface
.
This commit is contained in:
@@ -42,29 +42,29 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS';
|
||||
const CREATE = 'CHILL_EVENT_CREATE';
|
||||
const UPDATE = 'CHILL_EVENT_UPDATE';
|
||||
|
||||
|
||||
const ROLES = [
|
||||
self::SEE,
|
||||
self::SEE_DETAILS,
|
||||
self::CREATE,
|
||||
self::UPDATE
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @var AuthorizationHelper
|
||||
*/
|
||||
protected $authorizationHelper;
|
||||
|
||||
|
||||
/**
|
||||
* @var AccessDecisionManagerInterface
|
||||
*/
|
||||
protected $accessDecisionManager;
|
||||
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
|
||||
public function __construct(
|
||||
AccessDecisionManagerInterface $accessDecisionManager,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
@@ -75,7 +75,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
||||
public function supports($attribute, $subject)
|
||||
{
|
||||
return ($subject instanceof Event && in_array($attribute, self::ROLES))
|
||||
@@ -85,7 +85,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
(NULL === $subject && $attribute === self::SEE )
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $attribute
|
||||
@@ -96,30 +96,30 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
$this->logger->debug(sprintf("Voting from %s class", self::class));
|
||||
|
||||
|
||||
if (!$token->getUser() instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($subject instanceof Event) {
|
||||
return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
|
||||
|
||||
} elseif ($subject instanceof Person) {
|
||||
return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
// subject is null. We check that at least one center is reachable
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters($token->getUser(), new Role($attribute));
|
||||
|
||||
|
||||
return count($centers) > 0;
|
||||
}
|
||||
|
||||
|
||||
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return $this->authorizationHelper->userHasAccess(
|
||||
$token->getUser(),
|
||||
$subject,
|
||||
@@ -127,23 +127,22 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getRoles()
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
return self::ROLES;
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy()
|
||||
|
||||
public function getRolesWithHierarchy(): array
|
||||
{
|
||||
return [
|
||||
'Event' => self::ROLES
|
||||
];
|
||||
}
|
||||
|
||||
public function getRolesWithoutScope()
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
@@ -127,19 +127,19 @@ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierar
|
||||
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
public function getRoles(): array
|
||||
{
|
||||
return self::ROLES;
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy()
|
||||
public function getRolesWithHierarchy(): array
|
||||
{
|
||||
return [
|
||||
'Event' => self::ROLES
|
||||
];
|
||||
}
|
||||
|
||||
public function getRolesWithoutScope()
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user