Olivier Massot 5 месяцев назад
Родитель
Сommit
468f913acb
1 измененных файлов с 5 добавлено и 17 удалено
  1. 5 17
      src/Repository/Access/AccessRepository.php

+ 5 - 17
src/Repository/Access/AccessRepository.php

@@ -88,9 +88,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
      * @param bool $ignoreLoginEnabled               Retourne aussi les access dont la propriété loginEnabled est False
      */
     public function findAllValidAccesses(
-        Access $access,
-        bool $ignoreNetworkOrganizationEndDate = false,
-        bool $ignoreLoginEnabled = false,
+        Access $access
     ): mixed {
         $datetime = new \DateTime();
         $today = $datetime->format('Y-m-d');
@@ -103,23 +101,13 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
                 ->innerJoin('organization.networkOrganizations', 'networkOrganizations')
                 ->where('access.person = :person')
                 ->andWhere('networkOrganizations.startDate <= :today')
+                ->andWhere(
+                    "networkOrganizations.endDate >= :today
+                    OR networkOrganizations.endDate = '0000-00-00'
+                    OR networkOrganizations.endDate IS NULL")
                 ->setParameter('person', $access->getPerson())
                 ->setParameter('today', $today);
 
-            if (!$ignoreLoginEnabled) {
-                $q
-                    ->andWhere('access.loginEnabled = :loginEnabled')
-                    ->setParameter('loginEnabled', true);
-            }
-
-            if (!$ignoreNetworkOrganizationEndDate) {
-                $q->andWhere(
-                    "networkOrganizations.endDate >= :today 
-                    OR networkOrganizations.endDate = '0000-00-00' 
-                    OR networkOrganizations.endDate IS NULL"
-                );
-            }
-
             return $q->getQuery()->getResult();
         } finally {
             $this->filtersConfigurationService->restoreTimeConstraintFilters();