Fixed some exception about non existing part_attachments permission

This commit is contained in:
Jan Böhmer 2022-11-02 23:20:30 +01:00
parent 3e85fc4d42
commit 676235a2d3
3 changed files with 6 additions and 4 deletions

View file

@ -106,7 +106,7 @@ class AttachmentFormType extends AbstractType
'required' => false, 'required' => false,
'label' => 'attachment.edit.secure_file', 'label' => 'attachment.edit.secure_file',
'mapped' => false, 'mapped' => false,
'disabled' => !$this->security->isGranted('@parts_attachments.show_private'), 'disabled' => !$this->security->isGranted('@attachments.show_private'),
'help' => 'attachment.edit.secure_file.help', 'help' => 'attachment.edit.secure_file.help',
]); ]);

View file

@ -56,7 +56,7 @@ class AttachmentVoter extends ExtendedVoter
*/ */
protected function voteOnUser(string $attribute, $subject, User $user): bool protected function voteOnUser(string $attribute, $subject, User $user): bool
{ {
return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false; return $this->resolver->inherit($user, 'attachments', $attribute) ?? false;
} }
/** /**
@ -70,7 +70,7 @@ class AttachmentVoter extends ExtendedVoter
protected function supports(string $attribute, $subject): bool protected function supports(string $attribute, $subject): bool
{ {
if (is_a($subject, Attachment::class, true)) { if (is_a($subject, Attachment::class, true)) {
return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false); return in_array($attribute, $this->resolver->listOperationsForPermission('attachments'), false);
} }
//Allow class name as subject //Allow class name as subject

View file

@ -83,7 +83,9 @@ class PermissionVoter extends ExtendedVoter
$valid = $this->resolver->isValidOperation($perm, $op); $valid = $this->resolver->isValidOperation($perm, $op);
//if an invalid operation is encountered, throw an exception so the developer knows it //if an invalid operation is encountered, throw an exception so the developer knows it
//throw new \RuntimeException('Encountered invalid permission operation "'.$op.'" for permission "'.$perm.'"!'); if(!$valid) {
throw new \RuntimeException('Encountered invalid permission operation "'.$op.'" for permission "'.$perm.'"!');
}
return true; return true;
} }