Added permission to control if a user is allowed to withdraw/add/move parts

This commit is contained in:
Jan Böhmer 2023-01-07 21:23:36 +01:00
parent 89a4846259
commit 60d5776cb7
7 changed files with 55 additions and 5 deletions

View file

@ -57,7 +57,7 @@ class PartLotVoter extends ExtendedVoter
$this->security = $security;
}
protected const ALLOWED_PERMS = ['read', 'edit', 'create', 'delete', 'show_history', 'revert_element'];
protected const ALLOWED_PERMS = ['read', 'edit', 'create', 'delete', 'show_history', 'revert_element', 'withdraw', 'add', 'move'];
protected function voteOnUser(string $attribute, $subject, User $user): bool
{
@ -65,6 +65,11 @@ class PartLotVoter extends ExtendedVoter
throw new \RuntimeException('This voter can only handle PartLot objects!');
}
if (in_array($attribute, ['withdraw', 'add', 'move']))
{
return $this->resolver->inherit($user, 'parts_stock', $attribute) ?? false;
}
switch ($attribute) {
case 'read':
$operation = 'read';