浏览代码

Merge branch 'feature/V8-4411-page-licence-cmf' into develop

Olivier Massot 2 年之前
父节点
当前提交
c903374f01

+ 3 - 3
.env

@@ -46,8 +46,8 @@ MOBYT_API_BASE_URI=https://app.mobyt.fr/API/v1.0/REST/
 ###< mobyt client ###
 
 ###> knplabs/knp-snappy-bundle ###
-WKHTMLTOPDF_PATH=/usr/bin/wkhtmltopdf
-WKHTMLTOIMAGE_PATH=/usr/bin/wkhtmltoimage
+WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf
+WKHTMLTOIMAGE_PATH=/usr/local/bin/wkhtmltoimage
 ###< knplabs/knp-snappy-bundle ###
 
 ###> symfony/messenger ###
@@ -85,7 +85,7 @@ MERCURE_URL=xxx
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=xxx
 # The secret key used to sign the JWTs
-MERCURE_PUBLISHER_JWT_KEY=xxx
+MERCURE_JWT_SECRET=xxx
 ###< symfony/mercure-bundle ###
 
 ###> AdminAssos configuration ###

+ 1 - 1
config/packages/mercure.yaml

@@ -4,7 +4,7 @@ mercure:
             url: '%env(MERCURE_URL)%'
             public_url: '%env(MERCURE_PUBLIC_URL)%'
             jwt:
-                secret: '%env(MERCURE_PUBLISHER_JWT_KEY)%'
+                secret: '%env(MERCURE_JWT_SECRET)%'
                 algorithm: 'hmac.sha256'
                 publish: ['*']
 

+ 2 - 7
env/.env.docker

@@ -34,8 +34,8 @@ MERCURE_URL=http://mercure/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://local.mercure.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=gEwnJpcR8k0xE2sfBpEJzzuP2b2TXhZnzImIqCUk3j4RStBZa2pQjbEMsnGE4iGM
-###< symfony/mercure-bundle ###
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
+##< symfony/mercure-bundle ###
 
 ###> bindfile populate buffer file
 BIND_FILE_BUFFER_FILE=/var/www/html/var/subdomain.txt
@@ -52,8 +52,3 @@ LOG_FILE_NAME=docker
 ### Internal requests (@see doc/internal_requests.md)
 INTERNAL_FILES_DOWNLOAD_URI=https://nginx/_internal/secure/files
 ###
-
-###> knplabs/knp-snappy-bundle ###
-WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf
-WKHTMLTOIMAGE_PATH=/usr/local/bin/wkhtmltoimage
-###< knplabs/knp-snappy-bundle ###

+ 1 - 1
env/.env.test

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 1 - 1
env/.env.test1

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 1 - 1
env/.env.test2

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 1 - 1
env/.env.test3

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 1 - 1
env/.env.test4

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 1 - 1
env/.env.test5

@@ -30,7 +30,7 @@ MERCURE_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The public URL of the Mercure hub, used by the browser to connect
 MERCURE_PUBLIC_URL=https://mercure.test.opentalent.fr/.well-known/mercure
 # The secret used to sign the JWTs
-MERCURE_JWT_SECRET=NQEupdREijrfYvCmF2mnvZQFL9zLKDH9RCYter6tUWzjemPqzicffhc2fSf0yEmM
+MERCURE_JWT_SECRET=TXsLVKnU4Ew4oyH4qcQO81CuSOVTbj58W42fDTIzIZPwpPCaGu2EvIL3DbtDWtKHIGR6vvL98lnYlOADCB6buOvvfv30HL92OaBhB6jkyVnACipg7W4KQVRnQifiz3WymMnQYiprsBT9gyvRMTyhDHVDGaKrpgD1Y1j1pTR2JON9SSMHYTHsx6g7S7rKydgWEuNq4Jq2nldtYXXTYVRyZ2qKy5uGWfya2ahHsWGWTbz5UOkwN3b48fXpURSsMze4
 ###< symfony/mercure-bundle ###
 
 ###> filename log ###

+ 4 - 0
src/Filter/Doctrine/TimeConstraint/AbstractTimeFilter.php

@@ -46,6 +46,10 @@ abstract class AbstractTimeFilter extends SQLFilter
         $this->disabled = $disabled;
     }
 
+    public function isDisabled(): bool {
+        return $this->disabled;
+    }
+
     public function setAccessId(int $accessId): void {
         $this->accessId = $accessId;
     }

+ 10 - 9
src/Repository/Access/AccessRepository.php

@@ -14,6 +14,7 @@ use Doctrine\Persistence\ManagerRegistry;
 use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
 use Symfony\Component\Security\Core\User\UserInterface;
+use App\Service\Doctrine\FiltersConfigurationService;
 
 /**
  * @method Access|null find($id, $lockMode = null, $lockVersion = null)
@@ -26,7 +27,11 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
     const ACCESS_NAME_HEADER = 'X-AccessId';
     const HTTP_X_SWITCH_USER = 'X-Switch-User';
 
-    public function __construct(ManagerRegistry $registry, private RequestStack $requestStack)
+    public function __construct(
+        ManagerRegistry $registry,
+        private RequestStack $requestStack,
+        private FiltersConfigurationService $filtersConfigurationService
+    )
     {
         parent::__construct($registry, Access::class);
     }
@@ -112,9 +117,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
      */
     public function hasGotFunctionAtThisDate(Access $access, FunctionEnum $function, \DateTime $date): bool
     {
-        /** @var DatetimeFilter $filter */
-        $filter = $this->_em->getFilters()->getFilter('date_time_filter');
-        $filter->setDisabled(true);
+        $this->filtersConfigurationService->suspendTimeConstraintFilters();
 
         $qb = $this->createQueryBuilder('access');
         $qb
@@ -129,7 +132,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
 
         $result = count($qb->getQuery()->getResult()) > 0;
 
-        $filter->setDisabled(false);
+        $this->filtersConfigurationService->restoreTimeConstraintFilters();
 
         return $result;
     }
@@ -147,9 +150,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
         if ($date === null)
             $date = new DateTime();
 
-        /** @var DatetimeFilter $filter */
-        $filter = $this->_em->getFilters()->getFilter('date_time_filter');
-        $filter->setDisabled(true);
+        $this->filtersConfigurationService->suspendTimeConstraintFilters();
 
         $qb = $this->createQueryBuilder('access');
         $qb
@@ -164,7 +165,7 @@ class AccessRepository extends ServiceEntityRepository implements UserLoaderInte
 
         $result = $qb->getQuery()->getResult();
 
-        $filter->setDisabled(false);
+        $this->filtersConfigurationService->restoreTimeConstraintFilters();
 
         return $result;
     }

+ 7 - 5
src/Repository/Booking/CourseRepository.php

@@ -6,13 +6,17 @@ namespace App\Repository\Booking;
 use App\Entity\Booking\Course;
 use App\Entity\Organization\Organization;
 use App\Filter\Doctrine\TimeConstraint\AbstractTimeFilter;
+use App\Service\Doctrine\FiltersConfigurationService;
 use DateTimeInterface;
 use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 use Doctrine\Persistence\ManagerRegistry;
 
 class CourseRepository extends ServiceEntityRepository
 {
-    public function __construct(ManagerRegistry $registry)
+    public function __construct(
+        ManagerRegistry $registry,
+        private FiltersConfigurationService $filtersConfigurationService
+    )
     {
         parent::__construct($registry, Course::class);
     }
@@ -26,9 +30,7 @@ class CourseRepository extends ServiceEntityRepository
      */
     public function getCoursesToFrom(Organization $organization, DateTimeInterface $start, DateTimeInterface $end): array
     {
-        /** @var AbstractTimeFilter $filter */
-        $filter = $this->_em->getFilters()->getFilter('activity_year_filter');
-        $filter->setDisabled(true);
+        $this->filtersConfigurationService->suspendTimeConstraintFilters();
 
         $queryBuilder = $this->createQueryBuilder('course');
 
@@ -44,7 +46,7 @@ class CourseRepository extends ServiceEntityRepository
 
         $results = $queryBuilder->getQuery()->getResult();
 
-        $filter->setDisabled(false);
+        $this->filtersConfigurationService->restoreTimeConstraintFilters();
 
         return $results;
     }

+ 8 - 6
src/Repository/Education/EducationNotationRepository.php

@@ -6,12 +6,16 @@ namespace App\Repository\Education;
 use App\Entity\Education\EducationNotation;
 use App\Entity\Organization\Organization;
 use App\Filter\Doctrine\TimeConstraint\ActivityYearFilter;
+use App\Service\Doctrine\FiltersConfigurationService;
 use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 use Doctrine\Persistence\ManagerRegistry;
 
 class EducationNotationRepository extends ServiceEntityRepository
 {
-    public function __construct(ManagerRegistry $registry)
+    public function __construct(
+        ManagerRegistry $registry,
+        private FiltersConfigurationService $filtersConfigurationService
+    )
     {
         parent::__construct($registry, EducationNotation::class);
     }
@@ -22,9 +26,7 @@ class EducationNotationRepository extends ServiceEntityRepository
      * @return array|int|mixed|string
      */
     public function findAllEducationNotation(Organization $organization){
-        /** @var ActivityYearFilter $filter */
-        $filter = $this->_em->getFilters()->getFilter('activity_year_filter');
-        $filter->setDisabled(true);
+        $this->filtersConfigurationService->suspendTimeConstraintFilters();
 
         $queryBuilder = $this->createQueryBuilder('education_notation');
         $queryBuilder
@@ -39,8 +41,8 @@ class EducationNotationRepository extends ServiceEntityRepository
         $query = $queryBuilder->getQuery();
         $results = $query->getResult();
 
-        $filter->setDisabled(false);
+        $this->filtersConfigurationService->restoreTimeConstraintFilters();
 
         return $results;
     }
-}
+}

+ 7 - 3
src/Service/ApiLegacy/ApiLegacyRequestService.php

@@ -51,11 +51,11 @@ class ApiLegacyRequestService extends ApiRequestService
             'Content-Type' => 'application/ld+json',
         ];
 
-        /** @var Access $activeUser */
-        $activeUser = $token->getUser();
-
         $jwt = null;
         if ($token instanceof SwitchUserToken) {
+            /** @var Access $activeUser */
+            $activeUser = $token->getUser();
+
             /** @var Access|null $originalUser */
             $originalUser = $token->getOriginalToken()->getUser();
 
@@ -66,7 +66,11 @@ class ApiLegacyRequestService extends ApiRequestService
             $jwt = $this->jwtManager->create($originalUser->getPerson());
             $headers['x-accessid'] = $originalUser->getId();
             $headers['x-switch-access'] = $activeUser->getId();
+
         } elseif ($token !== null && !($token instanceof NullToken) && $token->getUser() !== null) {
+            /** @var Access $activeUser */
+            $activeUser = $token->getUser();
+
             $jwt = $this->jwtManager->create($activeUser->getPerson());
             $headers['x-accessid'] = $activeUser->getId();
         }

+ 60 - 0
src/Service/Doctrine/FiltersConfigurationService.php

@@ -19,6 +19,15 @@ use Doctrine\ORM\Query\FilterCollection;
  */
 class FiltersConfigurationService
 {
+    /**
+     * L'état du des filtres de contrainte de temps avant l'utilisation de la méthode suspendTimeConstraintFilters()
+     * Si $previousTimeConstraintState est `true`, les filtres étaient activés, et si c'est `false`, les filtres
+     * étaient désactivés. Si les filtres ne sont pas suspendus, $previousTimeConstraintState est null.
+     *
+     * @var bool|null
+     */
+    private ?bool $previousTimeConstraintState = null;
+
     public function __construct(
         private EntityManagerInterface $entityManager,
         private DateTimeConstraint $dateTimeConstraint,
@@ -50,4 +59,55 @@ class FiltersConfigurationService
         $activityYearFilter->setAccessId($accessId);
         $activityYearFilter->setTimeConstraint($this->activityYearConstraint);
     }
+
+    /**
+     * Suspends les contraintes de temps. Celles-ci pourront être restorées grâce à la méthode
+     * restoreTimeConstraintFilters().
+     *
+     * @see src/Filter/Doctrine/TimeConstraint/AbstractTimeFilter.php
+     *
+     * @return void
+     */
+    public function suspendTimeConstraintFilters(): void {
+        if ($this->previousTimeConstraintState !== null) {
+            throw new \RuntimeException("date_time_filter is already suspended");
+        }
+
+        $filters = $this->entityManager->getFilters();
+
+        if (!$filters->isEnabled('date_time_filter')) {
+            $this->previousTimeConstraintState = false;
+            return;
+        }
+
+        /** @var AbstractTimeFilter $filter */
+        $filter = $filters->getFilter('date_time_filter');
+
+        $this->previousTimeConstraintState = $filter->isDisabled() === false;
+        $filter->setDisabled(true);
+    }
+
+    /**
+     * Restore les contraintes de temps après qu'elles aient été suspendues au moyen de la
+     * méthode suspendTimeConstraintFilters()
+     *
+     * @see src/Filter/Doctrine/TimeConstraint/AbstractTimeFilter.php
+     *
+     * @return void
+     */
+    public function restoreTimeConstraintFilters(): void {
+        if ($this->previousTimeConstraintState === null) {
+            throw new \RuntimeException("date_time_filter has not been suspended, can not be restored");
+        }
+
+        $filters = $this->entityManager->getFilters();
+
+        if ($filters->isEnabled('date_time_filter')) {
+            /** @var AbstractTimeFilter $filter */
+            $filter = $filters->getFilter('date_time_filter');
+            $filter->setDisabled($this->previousTimeConstraintState);
+        }
+
+        $this->previousTimeConstraintState = null;
+    }
 }

+ 2 - 0
translations/enum/person/gender/messages+intl-icu.fr.yaml

@@ -1,2 +1,4 @@
 MISS: MME
 MISTER: MR
+MISS_LONG: Madame
+MISTER_LONG: Monsieur