浏览代码

Adds "Just Make It Work" functionality for Typo3 sites

Implements a new message and handler to simplify the Typo3 site management process.
Replaces the separate update and undelete calls with a single command that handles site creation, restoration, and updates.
This simplifies the logic and reduces the number of messages dispatched.
Olivier Massot 2 月之前
父节点
当前提交
74b9ebee7f

+ 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 - 4
src/Service/OnChange/Organization/OnParametersChange.php

@@ -9,6 +9,7 @@ use App\Entity\Education\EducationNotationConfig;
 use App\Entity\Organization\Parameters;
 use App\Entity\Organization\Parameters;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
 use App\Message\Message\Typo3\Typo3Delete;
 use App\Message\Message\Typo3\Typo3Delete;
+use App\Message\Message\Typo3\Typo3JustMakeItWork;
 use App\Message\Message\Typo3\Typo3Undelete;
 use App\Message\Message\Typo3\Typo3Undelete;
 use App\Message\Message\Typo3\Typo3Update;
 use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Booking\CourseRepository;
 use App\Repository\Booking\CourseRepository;
@@ -102,10 +103,7 @@ class OnParametersChange extends OnChangeDefault
                 );
                 );
             } else {
             } else {
                 $this->messageBus->dispatch(
                 $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]);
         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'.
      * Mark the given organization's website as deleted. This can be reverted with 'undeleteSite'.
      *
      *