Feat: Refactor application rejecting process

This commit is contained in:
Björn Fromme
2023-10-19 10:24:53 +02:00
parent 2c49c142b8
commit 21968b833c
12 changed files with 185 additions and 66 deletions
+3 -4
View File
@@ -12,7 +12,7 @@ class ApplicationVoter extends Voter
public const VIEW = 'VIEW';
public const DELETE = 'DELETE';
public const DISPOSE = 'DISPOSE';
public const REJECT = 'REJECT';
public const STATUS = 'STATUS';
protected function supports(string $attribute, mixed $subject): bool
{
@@ -20,7 +20,7 @@ class ApplicationVoter extends Voter
return false;
}
return in_array($attribute, [static::VIEW, static::DELETE, static::DISPOSE, static::REJECT]);
return in_array($attribute, [static::VIEW, static::DELETE, static::DISPOSE, static::STATUS]);
}
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
@@ -34,9 +34,8 @@ class ApplicationVoter extends Voter
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
$assignment = $application->getAssignment();
return match ($attribute) {
static::VIEW => true,
static::VIEW, static::STATUS => Application::STATUS_REJECTED !== $application->getStatus(),
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
static::DISPOSE => Application::STATUS_REJECTED !== $application->getStatus()
&& $assignment->getAvailableDispositions() > $assignment->getDispositions()->count(),
default => false,