Olivier Massot 1 gadu atpakaļ
vecāks
revīzija
8142b4023d

+ 1 - 1
config/packages/monolog.yaml

@@ -112,7 +112,7 @@ monolog:
             level: debug
             max_files: 7
             formatter: monolog.formatter.message
-            channels: ['cron']
+            channels: ['admin']
 
         # Rapport par mail
         admin_info:

+ 21 - 11
src/Service/Organization/OrganizationFactory.php

@@ -34,6 +34,7 @@ use Elastica\Param;
 use libphonenumber\NumberParseException;
 use libphonenumber\PhoneNumberUtil;
 use Psr\Log\LoggerInterface;
+use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\String\ByteString;
 use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
 use Symfony\Contracts\Service\Attribute\Required;
@@ -172,24 +173,33 @@ class OrganizationFactory
             throw $e;
         }
 
-        // Création du site typo3
+        // Register the subdomain into the BindFile (takes up to 5min to take effect)
+        $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
+        $this->logger->info("Subdomain registered");
+
+        // Création du site typo3 (on est obligé d'attendre que l'organisation soit persistée en base)
         if ($organizationCreationRequest->getCreateWebsite()) {
             $response = $this->typo3Service->createSite($organization->getId());
-
-            // TODO: revoir l'utilité du champs cmsId
             $rootPageUid = json_decode($response->getContent(), true);
-            $organization->setCmsId($rootPageUid);
-            $this->entityManager->persist($organization);
-            $this->entityManager->flush();
-            $this->logger->info("New typo3 website created (root uid : " . $rootPageUid . ")");
+
+            if (
+                $response->getStatusCode() === Response::HTTP_OK ||
+                !$rootPageUid
+            ) {
+                // TODO: revoir l'utilité du champs cmsId
+                $organization->setCmsId($rootPageUid);
+                $this->entityManager->persist($organization);
+                $this->entityManager->flush();
+                $this->logger->info("New typo3 website created (root uid : " . $rootPageUid . ")");
+
+            } else {
+                $this->logger->critical("/!\ A critical error happened while creating the Typo3 website ");
+                $this->logger->debug($response->getContent());
+            }
         } else {
             $this->logger->warning("Typo3 website creation was not required");
         }
 
-        // Register the subdomain into the BindFile (takes up to 5min to take effect)
-        $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
-        $this->logger->info("Subdomain registered");
-
         return $organization;
     }