add workflow on evaluationdocument in UI

This commit is contained in:
2022-02-27 02:38:08 +01:00
parent af0d7765ff
commit a9694da557
16 changed files with 244 additions and 66 deletions

View File

@@ -1,14 +1,24 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
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;
use UnexpectedValueException;
/**
* Voter for AccompanyingPeriodWorkEvaluationDocument
* Voter for AccompanyingPeriodWorkEvaluationDocument.
*
* Delegates to the sames authorization than for Evalution
*/
@@ -26,26 +36,27 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
protected function supports($attribute, $subject)
{
return $subject instanceof AccompanyingPeriodWorkEvaluationDocument
&& $attribute === self::SEE;
&& self::SEE === $attribute;
}
/**
* @param string $attribute
* @param AccompanyingPeriodWorkEvaluationDocument $subject
* @param TokenInterface $token
*
* @return bool|void
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
switch ($attribute){
switch ($attribute) {
case self::SEE:
return $this->accessDecisionManager->decide($token, [AccompanyingPeriodWorkEvaluationVoter::SEE],
$subject->getAccompanyingPeriodWorkEvaluation());
return $this->accessDecisionManager->decide(
$token,
[AccompanyingPeriodWorkEvaluationVoter::SEE],
$subject->getAccompanyingPeriodWorkEvaluation()
);
default:
throw new \UnexpectedValueException("The attribute $attribute is not supported");
throw new UnexpectedValueException("The attribute {$attribute} is not supported");
}
}
}