From 6177205e90e8c1386e0cced706fabd53d80584a8 Mon Sep 17 00:00:00 2001 From: yena Date: Fri, 29 Nov 2024 23:13:22 +0100 Subject: [PATCH] Do not filter displayed aliases in /alias --- src/Controller/AliasController.php | 9 +++------ src/Repository/AliasRepository.php | 8 +++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Controller/AliasController.php b/src/Controller/AliasController.php index 2366103d..1fe9dda8 100644 --- a/src/Controller/AliasController.php +++ b/src/Controller/AliasController.php @@ -20,10 +20,7 @@ class AliasController extends AbstractController public function __construct( private readonly AliasHandler $aliasHandler, private readonly EntityManagerInterface $manager, - ) - { - - } + ) {} #[Route(path: '/alias', name: 'aliases')] public function alias(Request $request): Response @@ -64,8 +61,8 @@ public function alias(Request $request): Response } $aliasRepository = $this->manager->getRepository(Alias::class); - $aliasesRandom = $aliasRepository->findByUser($user, true); - $aliasesCustom = $aliasRepository->findByUser($user, false); + $aliasesRandom = $aliasRepository->findByUser($user, true, true); + $aliasesCustom = $aliasRepository->findByUser($user, false, true); return $this->render( 'Start/aliases.html.twig', diff --git a/src/Repository/AliasRepository.php b/src/Repository/AliasRepository.php index a176010b..af9187ad 100644 --- a/src/Repository/AliasRepository.php +++ b/src/Repository/AliasRepository.php @@ -27,8 +27,14 @@ public function findOneBySource(string $email, ?bool $includeDeleted = false): ? * @param bool|null $random * @return array|Alias[] */ - public function findByUser(User $user, ?bool $random = null): array + public function findByUser(User $user, ?bool $random = null, ?bool $disableDomainFilter = false): array { + $filters = $this->getEntityManager()->getFilters(); + + if ($filters->isEnabled('domain_filter') && $disableDomainFilter == true) { + $filters->disable('domain_filter'); + } + if (isset($random)) { return $this->findBy(['user' => $user, 'random' => $random, 'deleted' => false]); }