mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Fixed coding style.
This commit is contained in:
parent
0a94689d98
commit
f2ff77a8b3
44 changed files with 435 additions and 387 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -21,26 +24,21 @@
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
||||
class LogEntryVoter extends ExtendedVoter
|
||||
{
|
||||
|
||||
public const ALLOWED_OPS = ['read', 'delete'];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
if ($subject instanceof AbstractLogEntry) {
|
||||
if ($attribute === 'delete') {
|
||||
if ('delete' === $attribute) {
|
||||
return $this->resolver->inherit($user, 'system', 'delete_logs') ?? false;
|
||||
}
|
||||
|
||||
if ($attribute === 'read') {
|
||||
if ('read' === $attribute) {
|
||||
//Allow read of the users own log entries
|
||||
if (
|
||||
$subject->getUser() === $user
|
||||
|
@ -49,22 +47,19 @@ class LogEntryVoter extends ExtendedVoter
|
|||
return true;
|
||||
}
|
||||
|
||||
return $this->resolver->inherit($user, 'system','show_logs') ?? false;
|
||||
return $this->resolver->inherit($user, 'system', 'show_logs') ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
if ($subject instanceof AbstractLogEntry) {
|
||||
return in_array($subject, static::ALLOWED_OPS);
|
||||
return in_array($subject, static::ALLOWED_OPS, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue