Forráskód Böngészése

Si moins de 5 films, le random a le droit de passer

Sangfroid 1 napja
szülő
commit
c54e737084
2 módosított fájl, 3 hozzáadás és 1 törlés
  1. 1 1
      config/packages/security.yaml
  2. 2 0
      src/Repository/FilmRepository.php

+ 1 - 1
config/packages/security.yaml

@@ -50,7 +50,7 @@ security:
 
     # Note: Only the *first* matching rule is applied
     access_control:
-        - { path: ^/(login$|register$|motdepasseoublie$|resetpassword/token=|activate/token=|attente$|fichefilm/|$|liste-by/|liste-by_real/|recherche|prochaines-sorties$|p/about$) , roles: PUBLIC_ACCESS }
+        - { path: ^/(login$|pif|register$|motdepasseoublie$|resetpassword/token=|activate/token=|attente$|fichefilm/|$|liste-by/|liste-by_real/|recherche|prochaines-sorties$|p/about$) , roles: PUBLIC_ACCESS }
         - { path: ^/admin, roles: ROLE_ADMIN }
         - { path: ^/genre, roles: ROLE_MODERATEUR }
         - { path: ^/p/edit, roles: ROLE_ADMIN }

+ 2 - 0
src/Repository/FilmRepository.php

@@ -233,6 +233,8 @@ class FilmRepository extends ServiceEntityRepository
             ->getResult();
         $ids = array_flip(array_map(fn($value): int => $value["id"], $films));
 
+        $nb = count($ids) >= 5 ? $nb : count($ids);
+
         $random = array_rand($ids, $nb);
 
         $qb = $this->createQueryBuilder("f");