浏览代码

Merge branch 'hotfix/V8-7171-cration-dorganisations--correcti'

Olivier Massot 9 月之前
父节点
当前提交
620b3a7ffe

+ 0 - 1
config/bundles.php

@@ -11,7 +11,6 @@ return [
     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],
     Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],

+ 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

+ 2 - 0
config/packages/messenger.yaml

@@ -16,3 +16,5 @@ framework:
             'App\Message\Message\Typo3\Typo3Update': async
             'App\Message\Message\Typo3\Typo3Delete': async
             'App\Message\Message\Typo3\Typo3Undelete': async
+            'App\Message\Message\OrganizationCreation': async
+            'App\Message\Message\OrganizationDeletion': async

+ 3 - 3
src/ApiResources/Organization/OrganizationCreationRequest.php

@@ -49,7 +49,7 @@ class OrganizationCreationRequest
     /**
      * Matricule (obligatoire dans le réseau CMF).
      */
-    #[Assert\Regex(pattern: '/^|(FR\d{12})$/')]
+    #[Assert\Regex(pattern: '/^|(FR\d{3}\w\d{8})$/')]
     private string $identifier = '';
 
     #[Assert\Regex(pattern: '/^|(\d+)$/')]
@@ -58,7 +58,7 @@ class OrganizationCreationRequest
     #[Assert\Regex(pattern: '/^|(W\d+)$/')]
     private string $waldecNumber = '';
 
-    private ?LegalEnum $legalStatus = null;
+    private LegalEnum $legalStatus;
 
     private SettingsProductEnum $product;
 
@@ -106,7 +106,7 @@ class OrganizationCreationRequest
     #[Assert\Positive]
     private int $parentId = OrganizationIdsEnum::_2IOS->value;
 
-    private ?PrincipalTypeEnum $principalType = null;
+    private PrincipalTypeEnum $principalType;
 
     /**
      * Id d'une Person existante ou requête de création d'un nouvel access qui aura le

+ 6 - 6
src/ApiResources/Organization/OrganizationMemberCreationRequest.php

@@ -15,7 +15,7 @@ class OrganizationMemberCreationRequest
     private GenderEnum $gender = GenderEnum::MISTER;
 
     #[Assert\Regex(pattern: '/^[a-z0-9\-]{3,}$/')]
-    private string $username;
+    private ?string $username = null;
 
     #[Assert\Length(
         min: 1,
@@ -57,7 +57,7 @@ class OrganizationMemberCreationRequest
         min: 10,
         minMessage: 'Phone number must be at least {{ limit }} characters long',
     )]
-    private string $phone;
+    private ?string $phone = null;
 
     #[Assert\Length(
         min: 10,
@@ -70,12 +70,12 @@ class OrganizationMemberCreationRequest
     )]
     private string $email;
 
-    public function getUsername(): string
+    public function getUsername(): ?string
     {
         return $this->username;
     }
 
-    public function setUsername(string $username): self
+    public function setUsername(?string $username): self
     {
         $this->username = $username;
 
@@ -190,12 +190,12 @@ class OrganizationMemberCreationRequest
         return $this;
     }
 
-    public function getPhone(): string
+    public function getPhone(): ?string
     {
         return $this->phone;
     }
 
-    public function setPhone(string $phone): self
+    public function setPhone(?string $phone): self
     {
         $this->phone = $phone;
 

+ 17 - 6
src/Service/Organization/OrganizationFactory.php

@@ -489,7 +489,7 @@ class OrganizationFactory
             throw new \RuntimeException('No parent organization found for id '.$organizationCreationRequest->getParentId());
         }
 
-        if ($parent->getSettings()->getProduct() !== SettingsProductEnum::MANAGER) {
+        if (!in_array($parent->getSettings()->getProduct(), [SettingsProductEnum::MANAGER, SettingsProductEnum::MANAGER_PREMIUM])) {
             throw new \RuntimeException("Parent organization must have the product 'manager' (actual product: '".$parent->getSettings()->getProduct()->value."')");
         }
 
@@ -502,7 +502,7 @@ class OrganizationFactory
 
         // Si réseau CMF, on vérifie que le matricule est valide
         if ($network->getId() === NetworkEnum::CMF->value) {
-            if (!preg_match("/FR\d{12}/", $organizationCreationRequest->getIdentifier())) {
+            if (!preg_match("/FR\d{3}\w\d{8}/", $organizationCreationRequest->getIdentifier())) {
                 throw new \RuntimeException('CMF identifier is missing or invalid.');
             }
         }
@@ -600,7 +600,10 @@ class OrganizationFactory
         } else {
             $person = new Person();
 
-            if ($this->personRepository->findOneBy(['username' => $creationRequestData->getUsername()])) {
+            if (
+                $creationRequestData->getUsername() !== null &&
+                $this->personRepository->findOneBy(['username' => $creationRequestData->getUsername()])
+            ) {
                 throw new \RuntimeException('Username already in use : '.$creationRequestData->getUsername());
             }
 
@@ -692,21 +695,29 @@ class OrganizationFactory
         \DateTime $creationDate,
         ?int $authorId,
     ): ContactPoint {
-        if (!$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getPhone())) {
+        if (
+            $organizationMemberCreationRequest->getPhone() !== null
+            && !$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getPhone())
+        ) {
             throw new \RuntimeException('Phone number is invalid or missing (person: '.$organizationMemberCreationRequest->getUsername().')');
         }
+
         if (
             $organizationMemberCreationRequest->getMobile() !== null
             && !$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getMobile())) {
             throw new \RuntimeException('Mobile phone number is invalid (person: '.$organizationMemberCreationRequest->getUsername().')');
         }
 
-        $phoneNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getPhone());
+
 
         $contactPoint = new ContactPoint();
         $contactPoint->setContactType(ContactPointTypeEnum::PRINCIPAL);
         $contactPoint->setEmail($organizationMemberCreationRequest->getEmail());
-        $contactPoint->setTelphone($phoneNumber);
+
+        if ($organizationMemberCreationRequest->getPhone() !== null) {
+            $phoneNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getPhone());
+            $contactPoint->setTelphone($phoneNumber);
+        }
 
         if ($organizationMemberCreationRequest->getMobile() !== null) {
             $mobileNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getMobile());