Browse Source

Merge branch 'v8-5587-filtre-evenement-mariage-examen' into 'develop'

V8 5587 filtre evenement mariage examen

See merge request opentalent/ap2i!84
Maha Bouchiba 1 năm trước cách đây
mục cha
commit
ef2e529881

+ 34 - 0
env/.env.test6

@@ -0,0 +1,34 @@
+###> symfony/framework-bundle ###
+APP_ENV=test
+APP_DEBUG=1
+###< symfony/framework-bundle ###
+
+###> api v1 ###
+API_LEG_BASE_URL=https://api.test6.opentalent.fr/api
+PUBLIC_API_LEG_BASE_URL=https://api.test6.opentalent.fr/api
+###< api v1 ###
+
+###> api v2 ###
+API_BASE_URL=https://ap2i.test6.opentalent.fr/api
+PUBLIC_API_BASE_URL=https://ap2i.test6.opentalent.fr/api
+###< api v2 ###
+
+###> typo3 client ###
+TYPO3_BASE_URI=http://test6.opentalent.fr/ohcluses
+###< typo3 client ###
+
+###> symfony/mercure-bundle ###
+# See https://symfony.com/doc/current/mercure.html#configuration
+# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
+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
+###< symfony/mercure-bundle ###
+
+###> filename log ###
+LOG_FILE_NAME=test
+###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://api.test6.opentalent.fr/_internal/secure/files
+###

+ 34 - 0
env/.env.test7

@@ -0,0 +1,34 @@
+###> symfony/framework-bundle ###
+APP_ENV=test
+APP_DEBUG=1
+###< symfony/framework-bundle ###
+
+###> api v1 ###
+API_LEG_BASE_URL=https://api.test7.opentalent.fr/api
+PUBLIC_API_LEG_BASE_URL=https://api.test7.opentalent.fr/api
+###< api v1 ###
+
+###> api v2 ###
+API_BASE_URL=https://ap2i.test7.opentalent.fr/api
+PUBLIC_API_BASE_URL=https://ap2i.test7.opentalent.fr/api
+###< api v2 ###
+
+###> typo3 client ###
+TYPO3_BASE_URI=http://test7.opentalent.fr/ohcluses
+###< typo3 client ###
+
+###> symfony/mercure-bundle ###
+# See https://symfony.com/doc/current/mercure.html#configuration
+# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
+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
+###< symfony/mercure-bundle ###
+
+###> filename log ###
+LOG_FILE_NAME=test
+###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://api.test7.opentalent.fr/_internal/secure/files
+###

+ 34 - 0
env/.env.test8

@@ -0,0 +1,34 @@
+###> symfony/framework-bundle ###
+APP_ENV=test
+APP_DEBUG=1
+###< symfony/framework-bundle ###
+
+###> api v1 ###
+API_LEG_BASE_URL=https://api.test8.opentalent.fr/api
+PUBLIC_API_LEG_BASE_URL=https://api.test8.opentalent.fr/api
+###< api v1 ###
+
+###> api v2 ###
+API_BASE_URL=https://ap2i.test8.opentalent.fr/api
+PUBLIC_API_BASE_URL=https://ap2i.test8.opentalent.fr/api
+###< api v2 ###
+
+###> typo3 client ###
+TYPO3_BASE_URI=http://test8.opentalent.fr/ohcluses
+###< typo3 client ###
+
+###> symfony/mercure-bundle ###
+# See https://symfony.com/doc/current/mercure.html#configuration
+# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
+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
+###< symfony/mercure-bundle ###
+
+###> filename log ###
+LOG_FILE_NAME=test
+###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://api.test8.opentalent.fr/_internal/secure/files
+###

+ 34 - 0
env/.env.test9

@@ -0,0 +1,34 @@
+###> symfony/framework-bundle ###
+APP_ENV=test
+APP_DEBUG=1
+###< symfony/framework-bundle ###
+
+###> api v1 ###
+API_LEG_BASE_URL=https://api.test9.opentalent.fr/api
+PUBLIC_API_LEG_BASE_URL=https://api.test9.opentalent.fr/api
+###< api v1 ###
+
+###> api v2 ###
+API_BASE_URL=https://ap2i.test9.opentalent.fr/api
+PUBLIC_API_BASE_URL=https://ap2i.test9.opentalent.fr/api
+###< api v2 ###
+
+###> typo3 client ###
+TYPO3_BASE_URI=http://test9.opentalent.fr/ohcluses
+###< typo3 client ###
+
+###> symfony/mercure-bundle ###
+# See https://symfony.com/doc/current/mercure.html#configuration
+# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
+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
+###< symfony/mercure-bundle ###
+
+###> filename log ###
+LOG_FILE_NAME=test
+###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://api.test9.opentalent.fr/_internal/secure/files
+###

+ 2 - 0
sql/schema-extensions/001-view_public_events.sql

@@ -8,6 +8,7 @@ AS
         b.url, 
         b.url, 
         b.datetimeStart, 
         b.datetimeStart, 
         b.datetimeEnd, 
         b.datetimeEnd, 
+        b.gender_id as gender,
         COALESCE(b.priceMini, 0) AS priceMini, 
         COALESCE(b.priceMini, 0) AS priceMini, 
         COALESCE(b.priceMaxi, 0) AS priceMaxi, 
         COALESCE(b.priceMaxi, 0) AS priceMaxi, 
         null as categoryCode,
         null as categoryCode,
@@ -54,6 +55,7 @@ UNION
         aw.deepLink AS url, 
         aw.deepLink AS url, 
         aw.datetimeStart, 
         aw.datetimeStart, 
         aw.datetimeEnd, 
         aw.datetimeEnd, 
+        NULL as gender,
         aw.priceMini, 
         aw.priceMini, 
         aw.priceMaxi, 
         aw.priceMaxi, 
         aw.subCategory AS categoryCode,
         aw.subCategory AS categoryCode,

+ 4 - 0
src/Commands/SetupEnvCommand.php

@@ -31,6 +31,10 @@ class SetupEnvCommand extends Command
         'test3' => '.env.test3',
         'test3' => '.env.test3',
         'test4' => '.env.test4',
         'test4' => '.env.test4',
         'test5' => '.env.test5',
         'test5' => '.env.test5',
+        'test6' => '.env.test6',
+        'test7' => '.env.test7',
+        'test8' => '.env.test8',
+        'test9' => '.env.test9',
         'ci' => '.env.staging',
         'ci' => '.env.staging',
     ];
     ];
 
 

+ 25 - 1
src/Entity/Public/PublicEvent.php

@@ -42,7 +42,7 @@ use Doctrine\ORM\Mapping as ORM;
 #[ApiFilter(filterClass: DistanceFilter::class)]
 #[ApiFilter(filterClass: DistanceFilter::class)]
 #[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart', 'datetimeEnd'], arguments: ['orderParameterName' => 'order'])]
 #[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart', 'datetimeEnd'], arguments: ['orderParameterName' => 'order'])]
 #[ApiFilter(filterClass: RangeFilter::class, properties: ['priceMini', 'priceMaxi'])]
 #[ApiFilter(filterClass: RangeFilter::class, properties: ['priceMini', 'priceMaxi'])]
-#[ApiFilter(filterClass: ArrayFieldFilter::class, properties: ['categories'])]
+#[ApiFilter(filterClass: ArrayFieldFilter::class, properties: ['categories', 'gender'])]
 class PublicEvent
 class PublicEvent
 {
 {
     #[ORM\Id]
     #[ORM\Id]
@@ -107,6 +107,10 @@ class PublicEvent
     #[ORM\Column(type: 'simple_array')]
     #[ORM\Column(type: 'simple_array')]
     private ?array $categories;
     private ?array $categories;
 
 
+    /** @var list<string>|null */
+    #[ORM\Column(type: 'simple_array')]
+    private ?array $gender;
+
     #[ORM\Column]
     #[ORM\Column]
     private string $origin = 'opentalent';
     private string $origin = 'opentalent';
 
 
@@ -369,6 +373,26 @@ class PublicEvent
         return $this;
         return $this;
     }
     }
 
 
+    /**
+     * @return string[]|null returns a list of gender identifiers as strings
+     */
+    public function getGender(): ?array
+    {
+        return $this->gender;
+    }
+
+    /**
+     * @param string[]|null $gender gender identifiers as a list of strings
+     *
+     * @return $this
+     */
+    public function setGender(?array $gender): PublicEvent
+    {
+        $this->gender = $gender;
+
+        return $this;
+    }
+
     public function getOrigin(): string
     public function getOrigin(): string
     {
     {
         return $this->origin;
         return $this->origin;

+ 13 - 14
src/Filter/ApiPlatform/Utils/ArrayFieldFilter.php

@@ -37,22 +37,21 @@ class ArrayFieldFilter extends AbstractFilter
             return;
             return;
         }
         }
 
 
-        $parameterName = $queryNameGenerator->generateParameterName($property);
-        $valueArray = json_decode($value, true);
+        // Vérifier si la valeur est déjà un tableau ou un JSON encodé
+        $values = json_decode($value, true);
 
 
-        if (is_array($valueArray)) {
-            $queryBuilder->andWhere($queryBuilder->expr()->orX(
-                ...array_map(function ($val) use ($queryBuilder, $property, $parameterName) {
-                    return $queryBuilder->expr()->like(sprintf('o.%s', $property), ':'.$parameterName);
-                }, $valueArray)
-            ));
-            foreach ($valueArray as $key => $val) {
-                $queryBuilder->setParameter($parameterName, '%'.$val.'%');
-            }
-        } else {
-            $queryBuilder->andWhere(sprintf('o.%s LIKE :%s', $property, $parameterName))
-                ->setParameter($parameterName, '%'.$value.'%');
+        // Si json_decode échoue ou si la valeur n'est pas un tableau, traiter comme une chaîne simple
+        if (JSON_ERROR_NONE !== json_last_error() || !is_array($values)) {
+            $values = [$value];
         }
         }
+
+        $orX = $queryBuilder->expr()->orX();
+        foreach ($values as $index => $val) {
+            $parameterName = $queryNameGenerator->generateParameterName($property.$index); // Générer un nom de paramètre unique
+            $orX->add($queryBuilder->expr()->like(sprintf('o.%s', $property), ':'.$parameterName));
+            $queryBuilder->setParameter($parameterName, '%'.$val.'%');
+        }
+        $queryBuilder->andWhere($orX);
     }
     }
 
 
     /**
     /**

+ 1 - 0
src/Service/Mailer/Builder/AbstractBuilder.php

@@ -43,6 +43,7 @@ class AbstractBuilder implements AbstractBuilderInterface
      */
      */
     public function buildEmailEntity(string $subject, Access $author, string $content): EmailEntity
     public function buildEmailEntity(string $subject, Access $author, string $content): EmailEntity
     {
     {
+        // todo : on aurait un setAuthor ou pas
         $emailEntity = new EmailEntity();
         $emailEntity = new EmailEntity();
         $emailEntity
         $emailEntity
             ->setAuthor($author)
             ->setAuthor($author)