mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 03:23:48 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -23,11 +23,8 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT';
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(private Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@@ -37,16 +34,10 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
/** @var Comment $subject */
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
case self::DELETE:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("This attribute {$attribute} is not supported");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
||||
self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
||||
default => throw new UnexpectedValueException("This attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,8 @@ class AccompanyingPeriodResourceVoter extends Voter
|
||||
{
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_RESOURCE_EDIT';
|
||||
|
||||
private AccessDecisionManagerInterface $accessDecisionManager;
|
||||
|
||||
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
|
||||
public function __construct(private AccessDecisionManagerInterface $accessDecisionManager)
|
||||
{
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@@ -35,17 +32,13 @@ class AccompanyingPeriodResourceVoter extends Voter
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource $subject */
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
return $this->accessDecisionManager->decide(
|
||||
$token,
|
||||
[AccompanyingPeriodVoter::EDIT],
|
||||
$subject->getAccompanyingPeriod()
|
||||
);
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("attribute not supported: {$attribute}");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::EDIT => $this->accessDecisionManager->decide(
|
||||
$token,
|
||||
[AccompanyingPeriodVoter::EDIT],
|
||||
$subject->getAccompanyingPeriod()
|
||||
),
|
||||
default => throw new UnexpectedValueException("attribute not supported: {$attribute}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -106,15 +106,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
||||
|
||||
private Security $security;
|
||||
|
||||
private VoterHelperInterface $voterHelper;
|
||||
|
||||
public function __construct(
|
||||
Security $security,
|
||||
private Security $security,
|
||||
VoterHelperFactoryInterface $voterHelperFactory
|
||||
) {
|
||||
$this->security = $security;
|
||||
$this->voterHelper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK])
|
||||
|
@@ -26,11 +26,8 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
||||
{
|
||||
public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW';
|
||||
|
||||
private AccessDecisionManagerInterface $accessDecisionManager;
|
||||
|
||||
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
|
||||
public function __construct(private AccessDecisionManagerInterface $accessDecisionManager)
|
||||
{
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@@ -47,16 +44,13 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
return $this->accessDecisionManager->decide(
|
||||
$token,
|
||||
[AccompanyingPeriodWorkEvaluationVoter::SEE],
|
||||
$subject->getAccompanyingPeriodWorkEvaluation()
|
||||
);
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("The attribute {$attribute} is not supported");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::SEE => $this->accessDecisionManager->decide(
|
||||
$token,
|
||||
[AccompanyingPeriodWorkEvaluationVoter::SEE],
|
||||
$subject->getAccompanyingPeriodWorkEvaluation()
|
||||
),
|
||||
default => throw new UnexpectedValueException("The attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -30,11 +30,8 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
||||
|
||||
public const STATS = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_STATS';
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(private Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@@ -49,15 +46,10 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
switch ($attribute) {
|
||||
case self::STATS:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject);
|
||||
|
||||
case self::SEE:
|
||||
return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("attribute {$attribute} is not supported");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject),
|
||||
self::SEE => $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork()),
|
||||
default => throw new UnexpectedValueException("attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -42,15 +42,12 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
||||
|
||||
public const UPDATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE';
|
||||
|
||||
private Security $security;
|
||||
|
||||
private VoterHelperInterface $voterHelper;
|
||||
|
||||
public function __construct(
|
||||
Security $security,
|
||||
private Security $security,
|
||||
VoterHelperFactoryInterface $voterHelperFactory
|
||||
) {
|
||||
$this->security = $security;
|
||||
$this->voterHelper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(null, [self::CREATE])
|
||||
@@ -98,34 +95,22 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
if ($subject instanceof AccompanyingPeriodWork) {
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject->getAccompanyingPeriod());
|
||||
|
||||
case self::CREATE:
|
||||
case self::UPDATE:
|
||||
case self::DELETE:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("attribute {$attribute} is not supported");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject->getAccompanyingPeriod()),
|
||||
self::CREATE, self::UPDATE, self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
|
||||
default => throw new UnexpectedValueException("attribute {$attribute} is not supported"),
|
||||
};
|
||||
} elseif ($subject instanceof AccompanyingPeriod) {
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject);
|
||||
|
||||
case self::CREATE:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::CREATE, $subject);
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException(sprintf(
|
||||
"attribute {$attribute} is not supported on instance %s",
|
||||
AccompanyingPeriod::class
|
||||
));
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject),
|
||||
self::CREATE => $this->security->isGranted(AccompanyingPeriodVoter::CREATE, $subject),
|
||||
default => throw new UnexpectedValueException(sprintf(
|
||||
"attribute {$attribute} is not supported on instance %s",
|
||||
AccompanyingPeriod::class
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", get_class($subject)));
|
||||
throw new UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", $subject::class));
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -17,13 +17,10 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
class AuthorizedCenterOnPersonCreation implements AuthorizedCenterOnPersonCreationInterface
|
||||
{
|
||||
private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser;
|
||||
|
||||
private bool $showCenters;
|
||||
|
||||
public function __construct(AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag)
|
||||
public function __construct(private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag)
|
||||
{
|
||||
$this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser;
|
||||
$this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user