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

organization creation : various fixes

Olivier Massot преди 1 година
родител
ревизия
aa610dbdb1
променени са 1 файла, в които са добавени 9 реда и са изтрити 6 реда
  1. 9 6
      src/Service/Organization/OrganizationFactory.php

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

@@ -108,7 +108,7 @@ class OrganizationFactory
 
             $this->logger->info("Organization persisted in the DB");
 
-        } catch (\Exception $e) {
+        } catch (\Throwable $e) {
             $this->logger->critical("An error happened, operation cancelled\n" . $e);
             $this->entityManager->rollback();
             throw $e;
@@ -123,7 +123,7 @@ class OrganizationFactory
                 $organizationCreationRequest->isClient()
             );
             $this->logger->info("New dolibarr structure created (uid : " . $dolibarrId . ")");
-        } catch (\Exception $e) {
+        } catch (\Throwable $e) {
             $this->logger->critical("An error happened while creating the dolibarr society, please proceed manually.");
             $this->logger->debug($e);
             $withError = true;
@@ -133,7 +133,7 @@ class OrganizationFactory
         try {
             $this->bindFileService->registerSubdomain($organizationCreationRequest->getSubdomain());
             $this->logger->info("Subdomain registered");
-        } catch (\Exception $e) {
+        } catch (\Throwable $e) {
             $this->logger->critical("An error happened while updating the bind file, please proceed manually.");
             $this->logger->debug($e);
             $withError = true;
@@ -141,8 +141,9 @@ class OrganizationFactory
         // Création du site typo3 (on est obligé d'attendre que l'organisation soit persistée en base)
         if ($organizationCreationRequest->getCreateWebsite()) {
             try {
-                $this->createTypo3Website($organization);
-            } catch (\Exception $e) {
+                $rootUid = $this->createTypo3Website($organization);
+                $this->logger->info("Typo3 website created (root uid: " . $rootUid . ")");
+            } catch (\Throwable $e) {
                 $this->logger->critical("An error happened while creating the typo3 website, please proceed manually.");
                 $this->logger->debug($e);
                 $withError = true;
@@ -297,6 +298,7 @@ class OrganizationFactory
         $organization->setPrincipalType($organizationCreationRequest->getPrincipalType());
         $organization->setIdentifier($organizationCreationRequest->getIdentifier());
         $organization->setCreationDate($organizationCreationRequest->getCreationDate());
+        $organization->setCreateDate($organizationCreationRequest->getCreationDate());
         $organization->setCreatedBy($organizationCreationRequest->getAuthorId());
         return $organization;
     }
@@ -606,7 +608,8 @@ class OrganizationFactory
      */
     protected function createTypo3Website(Organization $organization): ?int {
         $response = $this->typo3Service->createSite($organization->getId());
-        $rootPageUid = json_decode($response->getContent(), true);
+        $content = json_decode($response->getContent(), true);
+        $rootPageUid = $content['root_uid'];
 
         if ($response->getStatusCode() === Response::HTTP_OK && $rootPageUid > 0) {
             // TODO: revoir l'utilité du champs cmsId