Feat: Implement invoice pdf download for teamer

This commit is contained in:
Björn Fromme
2023-10-13 14:48:55 +02:00
parent 0685cd4c96
commit 98fc5fbf8b
5 changed files with 52 additions and 5 deletions
+10 -3
View File
@@ -13,6 +13,7 @@ class DispositionVoter extends Voter
public const EDIT = 'EDIT';
public const DELETE = 'DELETE';
public const CONTRACT = 'CONTRACT';
public const INVOICE = 'INVOICE';
protected function supports(string $attribute, mixed $subject): bool
{
@@ -20,7 +21,7 @@ class DispositionVoter extends Voter
return false;
}
return in_array($attribute, [static::VIEW, static::EDIT, static::DELETE, static::CONTRACT]);
return in_array($attribute, [static::VIEW, static::EDIT, static::DELETE, static::CONTRACT, static::INVOICE]);
}
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
@@ -31,14 +32,20 @@ class DispositionVoter extends Voter
}
// Teamers may only view or edit their own dispositions
if (in_array('ROLE_TEAMER', $token->getRoleNames()) && in_array($attribute, [static::VIEW, static::EDIT, static::CONTRACT])) {
if (in_array('ROLE_TEAMER', $token->getRoleNames())) {
/** @var User $user */
$user = $token->getUser();
$teamer = $user->getTeamer();
/** @var Disposition $disposition */
$disposition = $subject;
return $teamer === $disposition->getTeamer();
switch ($attribute) {
case static::VIEW:
case static::EDIT:
case static::CONTRACT:
case static::INVOICE:
return $teamer === $disposition->getTeamer();
}
}
return false;