mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
rename voter helepers
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||
|
||||
class DefaultVoter implements VoterInterface
|
||||
class DefaultVoterHelper implements VoterHelperInterface
|
||||
{
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
|
||||
@@ -50,14 +50,7 @@ class DefaultVoter implements VoterInterface
|
||||
}
|
||||
|
||||
if (NULL === $subject) {
|
||||
if (NULL === $center = $this->centerResolverDispatcher
|
||||
->resolveCenter($subject)) {
|
||||
return false;
|
||||
}
|
||||
return $this->authorizationHelper->userCanReachCenter(
|
||||
$token->getUser(),
|
||||
$center
|
||||
);
|
||||
return 0 < count($this->authorizationHelper->getReachableCenters($token->getUser(), $attribute, null));
|
||||
}
|
||||
|
||||
return $this->authorizationHelper->userHasAccess(
|
@@ -4,7 +4,7 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||
|
||||
class DefaultVoterFactory implements VoterFactoryInterface
|
||||
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
|
||||
{
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
protected CenterResolverDispatcher $centerResolverDispatcher;
|
||||
@@ -19,7 +19,7 @@ class DefaultVoterFactory implements VoterFactoryInterface
|
||||
|
||||
public function generate($context): VoterGeneratorInterface
|
||||
{
|
||||
return new VoterGenerator(
|
||||
return new DefaultVoterHelperGenerator(
|
||||
$this->authorizationHelper,
|
||||
$this->centerResolverDispatcher
|
||||
);
|
@@ -4,7 +4,7 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||
|
||||
final class VoterGenerator implements VoterGeneratorInterface
|
||||
final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
|
||||
{
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
protected CenterResolverDispatcher $centerResolverDispatcher;
|
||||
@@ -25,9 +25,9 @@ final class VoterGenerator implements VoterGeneratorInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function build(): VoterInterface
|
||||
public function build(): VoterHelperInterface
|
||||
{
|
||||
return new DefaultVoter(
|
||||
return new DefaultVoterHelper(
|
||||
$this->authorizationHelper,
|
||||
$this->centerResolverDispatcher,
|
||||
$this->configuration
|
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
interface VoterFactoryInterface
|
||||
{
|
||||
}
|
@@ -4,4 +4,12 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
interface VoterGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @param string $class The FQDN of a class
|
||||
* @param array $attributes an array of attributes
|
||||
* @return $this
|
||||
*/
|
||||
public function addCheckFor(string $class, array $attributes): self;
|
||||
|
||||
public function build(): VoterHelperInterface;
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
interface VoterHelperFactoryInterface
|
||||
{
|
||||
public function generate($context): VoterGeneratorInterface;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
interface VoterHelperInterface
|
||||
{
|
||||
public function supports($attribute, $subject): bool;
|
||||
|
||||
public function voteOnAttribute($attribute, $subject, TokenInterface $token);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
interface VoterInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user