فهرست منبع

Merge branch 'hotfix/V8-7844-site-internet-ne-se-cr-pas-pour-'

Olivier Massot 2 ماه پیش
والد
کامیت
6b121aff64

+ 26 - 0
src/Message/Handler/Typo3/Typo3JustMakeItWorkHandler.php

@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Message\Handler\Typo3;
+
+use App\Message\Message\Typo3\Typo3Update;
+use App\Service\Typo3\Typo3Service;
+use Symfony\Component\Messenger\Attribute\AsMessageHandler;
+
+#[AsMessageHandler(priority: 1)]
+class Typo3JustMakeItWorkHandler
+{
+    public function __construct(
+        private Typo3Service $typo3Service,
+    ) {
+    }
+
+    /**
+     * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
+     */
+    public function __invoke(Typo3Update $command): void
+    {
+        $this->typo3Service->justMakeItWorkSite($command->getOrganizationId());
+    }
+}

+ 26 - 0
src/Message/Message/Typo3/Typo3JustMakeItWork.php

@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Message\Message\Typo3;
+
+/**
+ * Envoi d'une requête JustMakeItWork à l'api Typo3.
+ */
+class Typo3JustMakeItWork
+{
+    public function __construct(
+        private int $organizationId,
+    ) {
+    }
+
+    public function getOrganizationId(): int
+    {
+        return $this->organizationId;
+    }
+
+    public function setOrganizationId(int $organizationId): void
+    {
+        $this->organizationId = $organizationId;
+    }
+}

+ 2 - 5
src/Service/OnChange/Organization/OnParametersChange.php

@@ -9,7 +9,7 @@ use App\Entity\Education\EducationNotationConfig;
 use App\Entity\Organization\Parameters;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
 use App\Message\Message\Typo3\Typo3Delete;
-use App\Message\Message\Typo3\Typo3Undelete;
+use App\Message\Message\Typo3\Typo3JustMakeItWork;
 use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Booking\CourseRepository;
 use App\Service\Network\Utils as NetworkUtils;
@@ -102,10 +102,7 @@ class OnParametersChange extends OnChangeDefault
                 );
             } else {
                 $this->messageBus->dispatch(
-                    new Typo3Undelete($parameters->getOrganization()->getId())
-                );
-                $this->messageBus->dispatch(
-                    new Typo3Update($parameters->getOrganization()->getId())
+                    new Typo3JustMakeItWork($parameters->getOrganization()->getId())
                 );
             }
         }

+ 12 - 0
src/Service/Typo3/Typo3Service.php

@@ -69,6 +69,18 @@ class Typo3Service
         return $this->sendCommand('/otadmin/site/update', ['organization-id' => $organizationId]);
     }
 
+    /**
+     * Update the organization's website if it exists, restore
+     * it if it has been deleted, or create it if it does not exist.
+     * Also removes any redirections that may have been set on the domain.
+     *
+     * @throws TransportExceptionInterface
+     */
+    public function justMakeItWorkSite(int $organizationId): ResponseInterface
+    {
+        return $this->sendCommand('/otadmin/site/just-make-it-work', ['organization-id' => $organizationId]);
+    }
+
     /**
      * Mark the given organization's website as deleted. This can be reverted with 'undeleteSite'.
      *

+ 4 - 7
tests/Unit/Service/OnChange/Organization/OnParametersChangeTest.php

@@ -12,7 +12,7 @@ use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
 use App\Message\Message\Typo3\Typo3Delete;
-use App\Message\Message\Typo3\Typo3Undelete;
+use App\Message\Message\Typo3\Typo3JustMakeItWork;
 use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Booking\CourseRepository;
 use App\Service\Network\Utils as NetworkUtils;
@@ -282,14 +282,11 @@ class OnParametersChangeTest extends TestCase
             ->getMock();
 
         $this->messageBus
-            ->expects(self::exactly(2))
+            ->expects(self::exactly(1))
             ->method('dispatch')
             ->willReturnCallback(function ($message) {
-                if ($message instanceof Typo3Undelete) {
-                    return new Envelope(new Typo3Undelete(1));
-                }
-                if ($message instanceof Typo3Update) {
-                    return new Envelope(new Typo3Update(1));
+                if ($message instanceof Typo3JustMakeItWork) {
+                    return new Envelope(new Typo3JustMakeItWork(1));
                 }
                 throw new \AssertionError('unexpected message : '.$message::class);
             });