Feat: Consider availability of dispositions in voter
This commit is contained in:
@@ -32,18 +32,23 @@ class ApplicationVoter extends Voter
|
||||
$application = $subject;
|
||||
|
||||
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
||||
$assignment = $application->getAssignment();
|
||||
return match ($attribute) {
|
||||
static::VIEW => true,
|
||||
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
|
||||
static::DISPOSE, static::REJECT => 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,
|
||||
};
|
||||
}
|
||||
|
||||
if ($user->hasRole('ROLE_TEAMER')) {
|
||||
return match ($attribute) {
|
||||
static::DELETE => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED === $application->getStatus(),
|
||||
static::VIEW => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED !== $application->getStatus(),
|
||||
static::DELETE => $user->getTeamer() === $application->getTeamer()
|
||||
&& Application::STATUS_REJECTED === $application->getStatus(),
|
||||
static::VIEW => $user->getTeamer() === $application->getTeamer()
|
||||
&& Application::STATUS_REJECTED !== $application->getStatus(),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user