mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 03:23:48 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class AccompanyingPeriodCommentVoter extends Voter
|
||||
{
|
||||
@@ -35,7 +34,7 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
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"),
|
||||
default => throw new \UnexpectedValueException("This attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class AccompanyingPeriodResourceVoter extends Voter
|
||||
{
|
||||
@@ -36,7 +35,7 @@ class AccompanyingPeriodResourceVoter extends Voter
|
||||
[AccompanyingPeriodVoter::EDIT],
|
||||
$subject->getAccompanyingPeriod()
|
||||
),
|
||||
default => throw new UnexpectedValueException("attribute not supported: {$attribute}"),
|
||||
default => throw new \UnexpectedValueException("attribute not supported: {$attribute}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,6 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
/**
|
||||
@@ -103,7 +101,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
final public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
||||
|
||||
/**
|
||||
* Right to see confidential period even if not referrer
|
||||
* Right to see confidential period even if not referrer.
|
||||
*/
|
||||
final public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
|
||||
|
||||
@@ -162,7 +160,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
|
||||
if ($subject instanceof AccompanyingPeriod) {
|
||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||
if (in_array($attribute, [self::EDIT, self::DELETE], true)) {
|
||||
if (\in_array($attribute, [self::EDIT, self::DELETE], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -183,7 +181,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
return false;
|
||||
}
|
||||
|
||||
if (in_array($attribute, [
|
||||
if (\in_array($attribute, [
|
||||
self::SEE, self::SEE_DETAILS, self::EDIT,
|
||||
], true)) {
|
||||
if ($subject->getUser() === $token->getUser()) {
|
||||
|
@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Voter for AccompanyingPeriodWorkEvaluationDocument.
|
||||
@@ -35,7 +34,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
* @param AccompanyingPeriodWorkEvaluationDocument $subject
|
||||
*
|
||||
* @return bool|void
|
||||
@@ -48,7 +47,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
|
||||
[AccompanyingPeriodWorkEvaluationVoter::SEE],
|
||||
$subject->getAccompanyingPeriodWorkEvaluation()
|
||||
),
|
||||
default => throw new UnexpectedValueException("The attribute {$attribute} is not supported"),
|
||||
default => throw new \UnexpectedValueException("The attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
use function in_array;
|
||||
|
||||
class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterInterface
|
||||
{
|
||||
@@ -35,11 +33,11 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
return $subject instanceof AccompanyingPeriodWorkEvaluation
|
||||
&& in_array($attribute, self::ALL, true);
|
||||
&& \in_array($attribute, self::ALL, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
* @param AccompanyingPeriodWorkEvaluation $subject
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
@@ -47,7 +45,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
|
||||
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"),
|
||||
default => throw new \UnexpectedValueException("attribute {$attribute} is not supported"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -21,9 +21,6 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
|
||||
class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface
|
||||
{
|
||||
@@ -81,15 +78,15 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
||||
return
|
||||
(
|
||||
$subject instanceof AccompanyingPeriodWork
|
||||
&& in_array($attribute, $this->getRoles(), true)
|
||||
&& \in_array($attribute, $this->getRoles(), true)
|
||||
) || (
|
||||
$subject instanceof AccompanyingPeriod
|
||||
&& in_array($attribute, [self::SEE, self::CREATE], true)
|
||||
&& \in_array($attribute, [self::SEE, self::CREATE], true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
* @param AccompanyingPeriodWork $subject
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
@@ -98,19 +95,16 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
|
||||
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"),
|
||||
default => throw new \UnexpectedValueException("attribute {$attribute} is not supported"),
|
||||
};
|
||||
} elseif ($subject instanceof AccompanyingPeriod) {
|
||||
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
|
||||
)),
|
||||
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", $subject::class));
|
||||
throw new \UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", $subject::class));
|
||||
}
|
||||
}
|
||||
|
@@ -21,8 +21,6 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
use function in_array;
|
||||
|
||||
class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface
|
||||
{
|
||||
@@ -71,7 +69,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
return ($subject instanceof Household
|
||||
&& in_array($attribute, self::ALL, true))
|
||||
&& \in_array($attribute, self::ALL, true))
|
||||
|| $this->helper->supports($attribute, $subject);
|
||||
}
|
||||
|
||||
@@ -81,7 +79,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
|
||||
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'),
|
||||
default => throw new \UnexpectedValueException('attribute not supported'),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user