mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
Feature: Add a list export for evaluation, actions and household
This commit is contained in:
@@ -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());
|
||||
|
||||
|
Reference in New Issue
Block a user