mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-31 03:53:49 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -45,11 +45,8 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
||||
|
||||
private VoterHelperInterface $helper;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security, VoterHelperFactoryInterface $voterHelperFactory)
|
||||
public function __construct(private Security $security, VoterHelperFactoryInterface $voterHelperFactory)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->helper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(Center::class, [self::STATS])
|
||||
@@ -80,19 +77,12 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
return $this->checkAssociatedMembersRole($subject, PersonVoter::SEE);
|
||||
|
||||
case self::EDIT:
|
||||
return $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE);
|
||||
|
||||
case self::STATS:
|
||||
return $this->voteOnAttribute($attribute, $subject, $token);
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('attribute not supported');
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE),
|
||||
self::EDIT => $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE),
|
||||
self::STATS => $this->voteOnAttribute($attribute, $subject, $token),
|
||||
default => throw new UnexpectedValueException('attribute not supported'),
|
||||
};
|
||||
}
|
||||
|
||||
private function checkAssociatedMembersRole(Household $household, string $attribute): bool
|
||||
|
Reference in New Issue
Block a user