mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
[feature] use internal services to check for acl on exports
This commit is contained in:
@@ -19,24 +19,23 @@ class ChillExportVoter extends Voter
|
||||
{
|
||||
public const EXPORT = 'chill_export';
|
||||
|
||||
protected AuthorizationHelperInterface $authorizationHelper;
|
||||
private VoterHelperInterface $helper;
|
||||
|
||||
public function __construct(AuthorizationHelperInterface $authorizationHelper)
|
||||
public function __construct(VoterHelperFactoryInterface $voterHelperFactory)
|
||||
{
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->helper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(null, [self::EXPORT])
|
||||
->build();
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
return self::EXPORT === $attribute;
|
||||
return $this->helper->supports($attribute, $subject);
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
if (!$token->getUser() instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [] !== $this->authorizationHelper->getReachableCenters($token->getUser(), $attribute);
|
||||
return $this->helper->voteOnAttribute($attribute, $subject, $token);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user