Feat: Refactor application rejecting process
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user