Преглед на файлове

upgrade to symfony7 (ongoing)

Olivier Massot преди 2 години
родител
ревизия
286b4ef406

+ 40 - 47
composer.json

@@ -2,77 +2,70 @@
   "type": "project",
   "license": "proprietary",
   "repositories": [
-    {
-      "type": "vcs",
-      "url": "ssh://git@gitlab.2iopenservice.com/vincent/foselastica.git"
-    },
     {
       "type": "vcs",
       "url": "ssh://git@gitlab.2iopenservice.com/opentalent/phpdocx.git"
     }
   ],
   "require": {
-    "php": ">=8.1",
+    "php": ">=8.2",
     "ext-ctype": "*",
     "ext-iconv": "*",
-    "api-platform/core": "3.1.7",
+    "api-platform/core": "3.2.7",
     "beberlei/doctrineextensions": "^1.3",
     "blackfire/php-sdk": "^1.23",
     "composer/package-versions-deprecated": "^1.11",
-    "doctrine/dbal": "^2.6",
-    "doctrine/doctrine-bundle": "^2.1",
+    "doctrine/dbal": "^3.7",
+    "doctrine/doctrine-bundle": "^2.11",
     "doctrine/doctrine-migrations-bundle": "^3.0",
-    "doctrine/orm": "^2.9",
-    "egulias/email-validator": "^3.0",
-    "jbouzekri/phumbor-bundle": "^3.1.0",
-    "knplabs/knp-gaufrette-bundle": "^0.8.0",
-    "knplabs/knp-snappy-bundle": "^1.9",
+    "doctrine/orm": "^2.17",
+    "egulias/email-validator": "^4.0",
+    "knplabs/knp-snappy-bundle": "*",
     "lcobucci/jwt": "^4.1",
     "lexik/jwt-authentication-bundle": "^2.8",
     "lorenzo/pinky": "^1.0",
     "myclabs/php-enum": "^1.7",
     "nelmio/cors-bundle": "^2.1",
     "odolbeau/phone-number-bundle": "^3.1",
+    "opentalent/phpdocx": "dev-master",
     "phpdocumentor/reflection-docblock": "^5.2",
     "ramsey/uuid": "^4.2",
     "ramsey/uuid-doctrine": "^2.0",
-    "symfony/asset": "6.3.*",
-    "symfony/console": "6.3.*",
-    "symfony/doctrine-messenger": "6.3.*",
-    "symfony/dotenv": "6.3.*",
-    "symfony/error-handler": "6.3.*",
-    "symfony/expression-language": "6.3.*",
-    "symfony/flex": "^1.3.1",
-    "symfony/framework-bundle": "6.3.*",
-    "symfony/http-client": "6.3.*",
-    "symfony/intl": "6.3.*",
-    "symfony/lock": "6.3.*",
-    "symfony/mailer": "6.3.*",
+    "symfony/asset": "7.0.*",
+    "symfony/console": "7.0.*",
+    "symfony/doctrine-messenger": "7.0.*",
+    "symfony/dotenv": "7.0.*",
+    "symfony/error-handler": "7.0.*",
+    "symfony/expression-language": "7.0.*",
+    "symfony/flex": "^2.4",
+    "symfony/framework-bundle": "7.0.*",
+    "symfony/http-client": "7.0.*",
+    "symfony/intl": "7.0.*",
+    "symfony/lock": "7.0.*",
+    "symfony/mailer": "7.0.*",
     "symfony/mercure": "^0.6.1",
     "symfony/mercure-bundle": "^0.3.4",
-    "symfony/messenger": "6.3.*",
+    "symfony/messenger": "7.0.*",
     "symfony/monolog-bundle": "^3.7",
     "symfony/polyfill-intl-icu": "^1.21",
     "symfony/polyfill-intl-messageformatter": "^1.24",
-    "symfony/property-access": "6.3.*",
-    "symfony/property-info": "6.3.*",
-    "symfony/security-bundle": "6.3.*",
-    "symfony/serializer": "6.3.*",
-    "symfony/translation": "6.3.*",
-    "symfony/twig-bundle": "6.3.*",
-    "symfony/uid": "6.3.*",
-    "symfony/validator": "6.3.*",
-    "symfony/yaml": "6.3.*",
+    "symfony/property-access": "7.0.*",
+    "symfony/property-info": "7.0.*",
+    "symfony/security-bundle": "7.0.*",
+    "symfony/serializer": "7.0.*",
+    "symfony/translation": "7.0.*",
+    "symfony/twig-bundle": "7.0.*",
+    "symfony/uid": "7.0.*",
+    "symfony/validator": "7.0.*",
+    "symfony/yaml": "7.0.*",
     "twig/cssinliner-extra": "^3.4",
     "twig/extra-bundle": "^3.4",
     "twig/inky-extra": "^3.4",
-    "vincent/foselastica": "1.3.1",
-    "opentalent/phpdocx": "dev-master",
-    "webonyx/graphql-php": "^14.3",
+    "webonyx/graphql-php": "^15.8",
     "xantios/mimey": "*"
   },
   "require-dev": {
-    "cyclonedx/cyclonedx-php-composer": "^3.4",
+    "cyclonedx/cyclonedx-php-composer": "^5.0",
     "dg/bypass-finals": "^1.4",
     "doctrine/doctrine-fixtures-bundle": "^3.4",
     "hautelook/alice-bundle": "^2.11",
@@ -83,14 +76,14 @@
     "phpstan/phpstan-phpunit": "^1.3",
     "phpstan/phpstan-symfony": "^1.2",
     "phpunit/phpunit": "^9.6",
-    "rector/rector": "^0.15.13",
-    "symfony/browser-kit": "6.3.*",
-    "symfony/css-selector": "6.3.*",
-    "symfony/debug-bundle": "6.3.*",
+    "rector/rector": "^0.18.12",
+    "symfony/browser-kit": "7.0.*",
+    "symfony/css-selector": "7.0.*",
+    "symfony/debug-bundle": "7.0.*",
     "symfony/maker-bundle": "^1.48",
-    "symfony/phpunit-bridge": "6.3.*",
-    "symfony/stopwatch": "6.3.*",
-    "symfony/web-profiler-bundle": "6.3.*",
+    "symfony/phpunit-bridge": "7.0.*",
+    "symfony/stopwatch": "7.0.*",
+    "symfony/web-profiler-bundle": "7.0.*",
     "timeweb/phpstan-enum": "^3.1",
     "zenstruck/foundry": "^1.31"
   },
@@ -149,7 +142,7 @@
   "extra": {
     "symfony": {
       "allow-contrib": false,
-      "require": "6.3.*"
+      "require": "7.0.*"
     },
     "phpstan": {
       "includes": [

+ 1 - 3
config/bundles.php

@@ -10,12 +10,10 @@ return [
     Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
     Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
     ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
-    Jb\Bundle\PhumborBundle\JbPhumborBundle::class => ['all' => true],
     Misd\PhoneNumberBundle\MisdPhoneNumberBundle::class => ['all' => true],
     Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
-    FOS\ElasticaBundle\FOSElasticaBundle::class => ['all' => true],
     Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],
-    Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
+//    Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
     Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
     Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
     Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],

+ 1 - 1
config/packages/docker/monolog.yaml

@@ -38,7 +38,7 @@ monolog:
             path: "%kernel.logs_dir%/%env(LOG_FILE_NAME)%.main.log"
             level: debug
             max_files: 3
-            channels: [php, doctrine, http_client, elastica]
+            channels: [php, doctrine, http_client]
         file_auth:
             type: rotating_file
             path: "%kernel.logs_dir%/%kernel.environment%.auth.log"

+ 0 - 27
config/packages/elastica.yaml

@@ -1,27 +0,0 @@
-imports:
-  - { resource: elastica/ }
-
-fos_elastica:
-  clients:
-    default: { host: '%env(resolve:ELASTICSEARCH_HOST)%', port: '%env(resolve:ELASTICSEARCH_PORT)%' }
-  indexes:
-    search:
-      use_alias: true
-      client: default
-      finder: ~
-      settings:
-        index:
-          analysis:
-            analyzer:
-              search_analyzer:
-                type:    custom
-                tokenizer:    standard
-                filter:    [standard, asciifolding ,lowercase]
-              custom_analyzer:
-                type:    custom
-                tokenizer:    standard
-                filter:    [standard, asciifolding ,lowercase]
-              custom_search_analyzer:
-                type:    custom
-                tokenizer:    standard
-                filter:    [standard, asciifolding ,lowercase]

+ 0 - 24
config/packages/elastica/educationNotation.yaml

@@ -1,24 +0,0 @@
-fos_elastica:
-  indexes:
-    search:
-      types:
-        educationNotation:
-          persistence:
-            driver: orm
-            model: 'App\Entity\Education\EducationNotation'
-            listener: ~
-            finder: ~
-            elastica_to_model_transformer:
-              ignore_missing: true
-          mappings:
-            id:
-              index: not_analyzed
-              type: integer
-            note_origine:
-              analyzer: custom_analyzer
-              search_analyzer: custom_search_analyzer
-              property_path: false
-            note_recalcul:
-              analyzer: custom_analyzer
-              search_analyzer: custom_search_analyzer
-              property_path: false

+ 0 - 20
config/packages/elastica/organization.yaml

@@ -1,20 +0,0 @@
-fos_elastica:
-  indexes:
-    search:
-      types:
-        organization:
-          persistence:
-            driver: orm
-            model: 'App\Entity\Organization\Organization'
-            listener: ~
-            finder: ~
-            elastica_to_model_transformer:
-              ignore_missing: true
-            provider: ~
-          mappings:
-            id:
-              index: not_analyzed
-              type: integer
-            name:
-              analyzer: custom_analyzer
-              search_analyzer: custom_search_analyzer

+ 0 - 11
config/packages/knp_gaufrette.yaml

@@ -1,11 +0,0 @@
-# @see https://github.com/KnpLabs/KnpGaufretteBundle
-# Documentation : https://knplabs.github.io/Gaufrette/basic-usage.html
-knp_gaufrette:
-  adapters:
-    storage:
-      local:
-        directory: '%kernel.project_dir%/var/files/storage'
-        create: true
-  filesystems:
-    storage:
-      adapter: storage

+ 0 - 9
config/packages/knp_snappy.yaml

@@ -1,9 +0,0 @@
-knp_snappy:
-    pdf:
-        enabled:    true
-        binary:     '%env(WKHTMLTOPDF_PATH)%'
-        options:    []
-    image:
-        enabled:    true
-        binary:     '%env(WKHTMLTOIMAGE_PATH)%'
-        options:    []

+ 1 - 1
config/packages/prod/monolog.yaml

@@ -38,7 +38,7 @@ monolog:
             path: "%kernel.logs_dir%/%env(LOG_FILE_NAME)%.main.log"
             level: debug
             max_files: 3
-            channels: [php, doctrine, http_client, elastica]
+            channels: [php, doctrine, http_client]
         file_auth:
             type: rotating_file
             path: "%kernel.logs_dir%/%kernel.environment%.auth.log"

+ 0 - 6
config/services.yaml

@@ -104,12 +104,6 @@ services:
     #########################################
     ##  LISTENER ##
 
-    #########################################
-    ##  ELASTIC SERVICE ##
-    App\Service\Elasticsearch\EducationNotationUpdater:
-        arguments:
-            - '@fos_elastica.object_persister.search.educationNotation'
-
     #########################################
     ## AutoWiring du service container ##
     Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'

+ 1 - 1
doc/logging.md

@@ -30,7 +30,7 @@ concernés :
         file_main:
             type: rotating_file
             [...]
-            channels: ["logger", "php", "doctrine", "http_client", "elastica"]
+            channels: ["logger", "php", "doctrine", "http_client"]
         file_auth:
             type: rotating_file
             [...]

+ 1 - 0
phpunit.xml.dist

@@ -7,6 +7,7 @@
         colors="true"
         bootstrap="tests/bootstrap.php"
         defaultTestSuite="unit"
+        verbose="true"
 >
   <coverage includeUncoveredFiles="true">
     <include>

+ 0 - 69
src/EventSubscriber/ElasticaPostTransformSubscriber.php

@@ -1,69 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace App\EventSubscriber;
-
-use App\Entity\Education\EducationNotation;
-use App\Service\Education\EducationNotationUtils;
-use FOS\ElasticaBundle\Event\PostTransformEvent;
-use FOS\ElasticaBundle\Event\PreTransformEvent;
-use FOS\ElasticaBundle\Event\TransformEvent;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-
-/**
- * Class ElasticaPostTransformSubscriber : Permet de réaliser des traitements avant et après un update d'un objet dans ES
- * @package App\EventSubscriber
- */
-final class ElasticaPostTransformSubscriber implements EventSubscriberInterface
-{
-    public function __construct(
-        private EducationNotationUtils $educationNotationUtils
-    )
-    {
-    }
-
-    /**
-     * ne se déclenche qu'après le post validate d'api platform
-     * @return string[]
-     */
-    public static function getSubscribedEvents(): array
-    {
-        return [
-            PreTransformEvent::class => 'doPostTransform',
-            PostTransformEvent::class => 'doPreTransform'
-        ];
-    }
-
-    /**
-     * Evénement se passant avant l'update d'un index ES
-     * @param TransformEvent $event
-     */
-    public function doPreTransform(TransformEvent $event): void
-    {
-
-    }
-
-    /**
-     * Evénement se passant après l'update d'un index ES
-     * @param TransformEvent $event
-     */
-    public function doPostTransform(TransformEvent $event): void
-    {
-        $document = $event->getDocument();
-        $object = $event->getObject();
-
-        if ($object instanceof EducationNotation) {
-            $this->educationNotationTransform($document, $object);
-        }
-    }
-
-    /**
-     * Recalcul et met à jour les note d'une évaluation suivant la note maximal configurée par la structure
-     * @param $document
-     * @param $object
-     */
-    private function educationNotationTransform(mixed $document, EducationNotation $educationNotation): void{
-        $document->set('note_origine', $this->educationNotationUtils->getNotationOriginal($educationNotation));
-        $document->set('note_recalcul', $this->educationNotationUtils->getNotationTransformed($educationNotation));
-    }
-}

+ 9 - 1
src/Serializer/DefaultNormalizer.php

@@ -41,6 +41,14 @@ final class DefaultNormalizer implements NormalizerInterface, DenormalizerInterf
         return $this->decorated->supportsNormalization($data, $format);
     }
 
+    /**
+     * @param string|null $format
+     * @return array
+     */
+    public function getSupportedTypes(?string $format): array {
+        return $this->decorated->getSupportedTypes($format);
+    }
+
     /**
      * @param $object
      * @param $format
@@ -48,7 +56,7 @@ final class DefaultNormalizer implements NormalizerInterface, DenormalizerInterf
      * @return mixed
      * @throws ExceptionInterface
      */
-    public function normalize($object, $format = null, array $context = []): mixed
+    public function normalize($object, ?string $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null
     {
         return $this->decorated->normalize($object, $format, $context);
     }

+ 0 - 24
src/Service/Elasticsearch/EducationNotationUpdater.php

@@ -1,24 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace App\Service\Elasticsearch;
-
-use FOS\ElasticaBundle\Persister\ObjectPersister;
-
-/**
- * Classe EducationNotationUpdater qui s'occupe de la mise à jour ES pour EducationNotation
- */
-class EducationNotationUpdater
-{
-    public function __construct(private ObjectPersister $objectPersisterEducationNotation)
-    {
-    }
-
-    /**
-     * Effectue le replace many des educations notations
-     * @param mixed[] $educationNotations
-     */
-    public function update(array $educationNotations): void{
-        $this->objectPersisterEducationNotation->replaceMany($educationNotations);
-    }
-}