mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Use imports instead of FQNs
This commit is contained in:
parent
f63b6d7207
commit
5629215ce4
179 changed files with 792 additions and 597 deletions
|
@ -98,7 +98,7 @@ class SamlUserFactory implements SamlUserFactoryInterface, EventSubscriberInterf
|
|||
//Check if we can find a group with the given ID
|
||||
if ($group_id !== null) {
|
||||
$group = $this->em->find(Group::class, $group_id);
|
||||
if ($group instanceof \App\Entity\UserSystem\Group) {
|
||||
if ($group instanceof Group) {
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentTypeAttachment;
|
||||
use App\Entity\Attachments\CategoryAttachment;
|
||||
|
@ -39,13 +41,12 @@ use App\Entity\UserSystem\User;
|
|||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class AttachmentVoter extends ExtendedVoter
|
||||
{
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ class AttachmentVoter extends ExtendedVoter
|
|||
if (is_object($subject)) {
|
||||
//If the attachment has no element (which should not happen), we deny access, as we can not determine if the user is allowed to access the associated element
|
||||
$target_element = $subject->getElement();
|
||||
if ($target_element instanceof \App\Entity\Attachments\AttachmentContainingDBElement) {
|
||||
if ($target_element instanceof AttachmentContainingDBElement) {
|
||||
return $this->security->isGranted($this->mapOperation($attribute), $target_element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ abstract class ExtendedVoter extends Voter
|
|||
/** @var UserRepository $repo */
|
||||
$repo = $this->entityManager->getRepository(User::class);
|
||||
$user = $repo->getAnonymousUser();
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,17 +22,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class LogEntryVoter extends ExtendedVoter
|
||||
{
|
||||
final public const ALLOWED_OPS = ['read', 'show_details', 'delete'];
|
||||
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, private readonly \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, private readonly Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
|
|
@ -41,15 +41,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class OrderdetailVoter extends ExtendedVoter
|
||||
{
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ class OrderdetailVoter extends ExtendedVoter
|
|||
};
|
||||
|
||||
//If we have no part associated use the generic part permission
|
||||
if (is_string($subject) || !$subject->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
if (is_string($subject) || !$subject->getPart() instanceof Part) {
|
||||
return $this->resolver->inherit($user, 'parts', $operation) ?? false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Parameters\AbstractParameter;
|
||||
use App\Entity\Parameters\AttachmentTypeParameter;
|
||||
use App\Entity\Parameters\CategoryParameter;
|
||||
|
@ -36,12 +38,11 @@ use App\Entity\UserSystem\User;
|
|||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class ParameterVoter extends ExtendedVoter
|
||||
{
|
||||
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ class ParameterVoter extends ExtendedVoter
|
|||
if (is_object($subject)) {
|
||||
//If the attachment has no element (which should not happen), we deny access, as we can not determine if the user is allowed to access the associated element
|
||||
$target_element = $subject->getElement();
|
||||
if ($target_element instanceof \App\Entity\Base\AbstractDBElement) {
|
||||
if ($target_element instanceof AbstractDBElement) {
|
||||
$operation = match ($attribute) {
|
||||
'read', 'view' => 'read',
|
||||
'edit', 'create', 'delete' => 'edit',
|
||||
|
|
|
@ -41,15 +41,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class PartLotVoter extends ExtendedVoter
|
||||
{
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ class PartLotVoter extends ExtendedVoter
|
|||
};
|
||||
|
||||
//If we have no part associated use the generic part permission
|
||||
if (is_string($subject) || !$subject->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
if (is_string($subject) || !$subject->getPart() instanceof Part) {
|
||||
return $this->resolver->inherit($user, 'parts', $operation) ?? false;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,15 +41,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\UserSystem\PermissionManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class PricedetailVoter extends ExtendedVoter
|
||||
{
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(PermissionManager $resolver, EntityManagerInterface $entityManager, protected Security $security)
|
||||
{
|
||||
parent::__construct($resolver, $entityManager);
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ class PricedetailVoter extends ExtendedVoter
|
|||
};
|
||||
|
||||
//If we have no part associated use the generic part permission
|
||||
if (is_string($subject) || !$subject->getOrderdetail() instanceof \App\Entity\PriceInformations\Orderdetail || !$subject->getOrderdetail()->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
if (is_string($subject) || !$subject->getOrderdetail() instanceof Orderdetail || !$subject->getOrderdetail()->getPart() instanceof Part) {
|
||||
return $this->resolver->inherit($user, 'parts', $operation) ?? false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue