finalize handling workflow for evaluation document

This commit is contained in:
2022-02-25 15:40:23 +01:00
parent 356d1a7133
commit da019a146a
4 changed files with 61 additions and 2 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace Chill\PersonBundle\Security\Authorization;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
/**
* Voter for AccompanyingPeriodWorkEvaluationDocument
*
* Delegates to the sames authorization than for Evalution
*/
class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
{
public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW';
private AccessDecisionManagerInterface $accessDecisionManager;
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
{
$this->accessDecisionManager = $accessDecisionManager;
}
protected function supports($attribute, $subject)
{
return $subject instanceof AccompanyingPeriodWorkEvaluationDocument
&& $attribute === self::SEE;
}
/**
* @param string $attribute
* @param AccompanyingPeriodWorkEvaluationDocument $subject
* @param TokenInterface $token
* @return bool|void
*/
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");
}
}
}