Feature: Add a list export for evaluation, actions and household

This commit is contained in:
2023-01-26 14:22:30 +00:00
committed by Julien Fastré
parent 9ada19ef23
commit e54c2ca712
24 changed files with 1323 additions and 50 deletions

View File

@@ -11,16 +11,25 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Security\Authorization;
use Chill\MainBundle\Security\Authorization\ChillVoterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
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
class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterInterface
{
public const ALL = [
self::SEE,
self::STATS,
];
public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_SHOW';
public const STATS = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_STATS';
private Security $security;
public function __construct(Security $security)
@@ -31,7 +40,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter
protected function supports($attribute, $subject)
{
return $subject instanceof AccompanyingPeriodWorkEvaluation
&& self::SEE === $attribute;
&& in_array($attribute, self::ALL, true);
}
/**
@@ -41,6 +50,9 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
switch ($attribute) {
case self::STATS:
return $this->security->isGranted(AccompanyingPeriodWorkVoter::STATS, $subject);
case self::SEE:
return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork());