WIP: Implement voter

This commit is contained in:
Björn Fromme
2023-10-11 16:11:48 +02:00
parent 79e4fe0f33
commit 088c5546e7
2 changed files with 27 additions and 8 deletions
+10 -5
View File
@@ -31,18 +31,23 @@ class ApplicationVoter extends Voter
/** @var Application $application */
$application = $subject;
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(),
default => false,
};
}
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
return match ($attribute) {
static::VIEW, static::DELETE => true,
static::VIEW => true,
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
default => false,
};
}
if (static::VIEW === $attribute && $user->hasRole('ROLE_TEAMER')) {
return $user->getTeamer() === $application->getTeamer();
}
return false;
}
}