WIP: Implement application handling

This commit is contained in:
Björn Fromme
2023-10-11 15:43:33 +02:00
parent b472dab6c8
commit 79e4fe0f33
7 changed files with 193 additions and 29 deletions
+9 -3
View File
@@ -11,6 +11,8 @@ class ApplicationVoter extends Voter
{
public const VIEW = 'VIEW';
public const DELETE = 'DELETE';
public const DISPOSE = 'DISPOSE';
public const REJECT = 'REJECT';
protected function supports(string $attribute, mixed $subject): bool
{
@@ -18,7 +20,7 @@ class ApplicationVoter extends Voter
return false;
}
return in_array($attribute, [static::VIEW, static::DELETE]);
return in_array($attribute, [static::VIEW, static::DELETE, static::DISPOSE, static::REJECT]);
}
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
@@ -30,10 +32,14 @@ class ApplicationVoter extends Voter
$application = $subject;
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
return true;
return match ($attribute) {
static::VIEW, static::DELETE => true,
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
default => false,
};
}
if ($user->hasRole('ROLE_TEAMER')) {
if (static::VIEW === $attribute && $user->hasRole('ROLE_TEAMER')) {
return $user->getTeamer() === $application->getTeamer();
}