WIP: Implement application handling
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user