mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Fixed code style.
This commit is contained in:
parent
1aed1d1d26
commit
9a7223a301
142 changed files with 534 additions and 716 deletions
|
@ -80,16 +80,18 @@ class ElementPermissionListener
|
|||
/**
|
||||
* Checks if access to the property of the given element is granted.
|
||||
* This function adds an additional cache layer, where the voters are called only once (to improve performance).
|
||||
* @param string $mode What operation should be checked. Must be 'read' or 'edit'
|
||||
*
|
||||
* @param string $mode What operation should be checked. Must be 'read' or 'edit'
|
||||
* @param ColumnSecurity $annotation The annotation of the property that should be checked
|
||||
* @param DBElement $element The element that should for which should be checked
|
||||
* @param DBElement $element The element that should for which should be checked
|
||||
*
|
||||
* @return bool True if the user is allowed to read that property
|
||||
*/
|
||||
protected function isGranted(string $mode, ColumnSecurity $annotation, DBElement $element) : bool
|
||||
protected function isGranted(string $mode, ColumnSecurity $annotation, DBElement $element): bool
|
||||
{
|
||||
if ($mode === 'read') {
|
||||
if ('read' === $mode) {
|
||||
$operation = $annotation->getReadOperationName();
|
||||
} elseif ($mode === 'edit') {
|
||||
} elseif ('edit' === $mode) {
|
||||
$operation = $annotation->getEditOperationName();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('$mode must be either "read" or "edit"!');
|
||||
|
@ -101,12 +103,11 @@ class ElementPermissionListener
|
|||
}
|
||||
|
||||
//Check if we have already have saved the permission, otherwise save it to cache
|
||||
if (!isset($this->perm_cache[$mode][get_class($element)][$operation])) {
|
||||
$this->perm_cache[$mode][get_class($element)][$operation] = $this->security->isGranted($operation, $element);
|
||||
if (!isset($this->perm_cache[$mode][\get_class($element)][$operation])) {
|
||||
$this->perm_cache[$mode][\get_class($element)][$operation] = $this->security->isGranted($operation, $element);
|
||||
}
|
||||
|
||||
return $this->perm_cache[$mode][get_class($element)][$operation];
|
||||
|
||||
return $this->perm_cache[$mode][\get_class($element)][$operation];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,13 +26,11 @@ use Symfony\Component\Security\Core\Exception\AccountStatusException;
|
|||
use Symfony\Component\Security\Core\Exception\DisabledException;
|
||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class UserChecker implements UserCheckerInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,8 +32,6 @@ class AttachmentVoter extends ExtendedVoter
|
|||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -72,7 +72,6 @@ abstract class ExtendedVoter extends Voter
|
|||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function voteOnUser($attribute, $subject, User $user): bool;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ class GroupVoter extends ExtendedVoter
|
|||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ class PermissionVoter extends ExtendedVoter
|
|||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
|
@ -54,9 +54,9 @@ class StructureVoter extends ExtendedVoter
|
|||
/**
|
||||
* Maps a instance type to the permission name.
|
||||
*
|
||||
* @param $subject mixed The subject for which the permission name should be generated.
|
||||
* @param $subject mixed The subject for which the permission name should be generated
|
||||
*
|
||||
* @return string|null The name of the permission for the subject's type or null, if the subject is not supported.
|
||||
* @return string|null the name of the permission for the subject's type or null, if the subject is not supported
|
||||
*/
|
||||
protected function instanceToPermissionName($subject): ?string
|
||||
{
|
||||
|
@ -91,8 +91,6 @@ class StructureVoter extends ExtendedVoter
|
|||
*
|
||||
* @param $attribute
|
||||
* @param $subject
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue