浏览代码

Merge branch 'hotfix/bug-on-subdomain-change' into develop

Olivier Massot 3 年之前
父节点
当前提交
180d745836
共有 3 个文件被更改,包括 32 次插入2 次删除
  1. 0 0
      .env.docker
  2. 26 0
      doc/env.md
  3. 6 2
      src/Service/OnChange/Organization/OnSubdomainChange.php

+ 0 - 0
.env.docker


+ 26 - 0
doc/env.md

@@ -0,0 +1,26 @@
+## Gestion des variables d'environnement
+
+Les variables d'environnement sont définies dans les fichiers .env (dotenv)
+
+> Voir <https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables>
+
+### Principe général
+
+Les fichiers dotenv s'organisent ainsi :
+
+Un fichier `.env` commun à tous les environnements, il définit des valeurs par défaut.
+
+Un fichier `.env.local` : il ne doit **pas** être versionné et contiendra des variables propres à l'environnement local.
+C'est lui qui définit le nom de l'environnement, par exemple : 
+
+    APP_ENV=prod
+
+Un fichier `.env.<environnement>` qui ne s'appliquera qu'à l'environnement donné. Cet environnement est défini par la 
+variable d'environnement `APP_ENV` (voir plus haut).
+
+
+### Déboguer
+
+Les variables d'environnement actives peuvent être affichées au moyen de la commande :
+
+    php bin/console debug:container --env-vars

+ 6 - 2
src/Service/OnChange/Organization/OnSubdomainChange.php

@@ -2,6 +2,7 @@
 
 namespace App\Service\OnChange\Organization;
 
+use App\Entity\Organization\Organization;
 use App\Entity\Organization\Subdomain;
 use App\Message\Command\MailerCommand;
 use App\Message\Command\Typo3\Typo3UpdateCommand;
@@ -13,6 +14,7 @@ use App\Service\OnChange\OnChangeDefault;
 use App\Service\Organization\Utils as OrganizationUtils;
 use App\Service\Typo3\BindFileService;
 use App\Tests\Service\OnChange\Organization\OnSubdomainChangeTest;
+use Doctrine\ORM\EntityManagerInterface;
 use Symfony\Component\Messenger\MessageBusInterface;
 use Symfony\Component\Security\Core\Security;
 
@@ -22,7 +24,8 @@ class OnSubdomainChange extends OnChangeDefault
         private OrganizationUtils $organizationUtils,
         private BindFileService $bindFileService,
         private MessageBusInterface $messageBus,
-        private Security $security
+        private Security $security,
+        private EntityManagerInterface $em
     ) {}
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
@@ -51,7 +54,6 @@ class OnSubdomainChange extends OnChangeDefault
 
     /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
     public function onChange($subdomain, OnChangeContext $context): void {
-
         // Register into the BindFile
         if ($context->isPostRequest()) {
             $this->bindFileService->registerSubdomain($subdomain->getSubdomain());
@@ -60,6 +62,8 @@ class OnSubdomainChange extends OnChangeDefault
         // A new subdomain is active
         // /!\ This has to be executed after everything has been persisted
         if ($subdomain->isActive() && !($context->previousData() && $context->previousData()->isActive())) {
+            // TODO: comprendre pourquoi ce refresh est indispensable pour le l'organisation soit à jour
+            $this->em->refresh($subdomain->getOrganization());
 
             // Update the typo3 website (asynchronously with messenger)
             $this->messageBus->dispatch(