Преглед изворни кода

fix duplicated modules in config

Olivier Massot пре 2 година
родитељ
комит
31eac358a1

+ 0 - 7
config/opentalent/modulesbyconditions.yaml

@@ -74,13 +74,6 @@ opentalent:
                 service:
                     name: App\Service\Cotisation\Utils
                     function: isManagerAndCMF
-        Statistic:
-            roles:
-                - ROLE_STATISTIC
-            conditions:
-                service:
-                    name: App\Service\Cotisation\Utils
-                    function: isStructure
         Network:
             conditions:
                 service:

+ 0 - 1
config/opentalent/products.yaml

@@ -282,7 +282,6 @@ opentalent:
           - Messages
           - Tagg
           - Statistic
-          - Cotisation
           - Dolibarr
 
       artist_premium:

+ 0 - 14
src/Service/Cotisation/Utils.php

@@ -43,20 +43,6 @@ class Utils
         return $this->networkOrganizationRepository->isLastParent($organization) && $this->networkUtils->isCMF($organization);
     }
 
-    /**
-     * Test si l'organisation est une structure (non manager)
-     * @see config/opentalent/modulesbyconditions.yaml
-     *
-     * @param Organization $organization
-     * @return bool
-     * @see UtilsTest::testIsStructure()
-     */
-    public function isStructure(Organization $organization): bool
-    {
-        return true;  // TODO: revoir la définition dans la V1 :  https://gitlab.2iopenservice.com/opentalent/opentalent-platform/-/blob/master/src/AppBundle/Services/Cotisation/Utils.php#L144
-//        return $this->organizationUtils->isStructure($organization);
-    }
-
     /**
      * Test si l'organisation est une structure (non manager) ET appartient à la CMF
      * @see config/opentalent/modulesbyconditions.yaml

+ 14 - 0
src/Service/Security/Module.php

@@ -46,12 +46,26 @@ class Module
 //            return $cacheDriver->fetch('organization_modules_' . $organization->getId());
 //        }
 
+        // Get modules from the organization settings
         $modulesBySettings = $this->getModuleBySettings($organization);
 
+        // Get modules according to the conditions defined in the config
         $modulesByConditions = $this->getModulesByConditions($organization);
 
+        // Get the modules from the owned product
         $product = $organization->getSettings()->getProduct();
         $modulesForProduct = $this->getModulesByProductConfiguration($product);
+        
+        // Controls that no modules where setup in different locations (this should not happen, and can lead to unexpected
+        // behaviors whend serializing the OrganizationProfile)
+        $intersection = array_merge(
+            array_intersect($modulesBySettings, $modulesByConditions),
+            array_intersect($modulesByConditions, $modulesForProduct),
+            array_intersect($modulesBySettings, $modulesForProduct)
+        );
+        if (!empty($intersection)) {
+            throw new \RuntimeException("Those modules are defined more than once : " . implode(', ', $intersection));
+        }
 
         $organizationModules = array_merge_recursive($modulesForProduct, $modulesBySettings, $modulesByConditions);