浏览代码

complete subdomain add command

Olivier Massot 2 年之前
父节点
当前提交
6062bf00f9
共有 1 个文件被更改,包括 23 次插入7 次删除
  1. 23 7
      src/Service/Typo3/SubdomainService.php

+ 23 - 7
src/Service/Typo3/SubdomainService.php

@@ -120,16 +120,32 @@ class SubdomainService
         $subdomain->setOrganization($organization);
         $subdomain->setActive(false);
 
-        $this->em->persist($subdomain);
-        $this->em->flush();
+        $this->em->beginTransaction();
 
-        // Register into the BindFile (takes up to 5min to take effect)
-        $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
+        try {
 
-        if ($activate) {
-            $subdomain = $this->activateSubdomain($subdomain);
-        }
+            // <--- Pour la rétrocompatibilité avec la v1; pourra être supprimé lorsque la migration sera achevée
+            $parameters = $organization->getParameters();
+            $parameters->setSubDomain($subdomainValue);
+            $parameters->setOtherWebsite('https://' . $subdomainValue . '.opentalent.fr');
+            $this->em->persist($parameters);
+            // --->
+
+            $this->em->persist($subdomain);
+            $this->em->flush();
+
+            // Register into the BindFile (takes up to 5min to take effect)
+            $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
 
+            if ($activate) {
+                $subdomain = $this->activateSubdomain($subdomain);
+            }
+
+            $this->em->commit();
+        } catch (\Throwable $e) {
+            $this->em->rollback();
+            throw $e;
+        }
         return $subdomain;
     }