Просмотр исходного кода

messenger: rename Commands into Messages

Olivier Massot 10 месяцев назад
Родитель
Сommit
b1244f7b84

+ 1 - 1
src/Message/Handler/ExportHandler.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 
 namespace App\Message\Handler;
 
-use App\Message\Command\Export;
+use App\Message\Message\Export;
 use App\Repository\Access\AccessRepository;
 use App\Service\MercureHub;
 use App\Service\Notifier;

+ 1 - 1
src/Message/Handler/MailerHandler.php

@@ -5,7 +5,7 @@ declare(strict_types=1);
 namespace App\Message\Handler;
 
 use App\Entity\Message\Email;
-use App\Message\Command\MailerCommand;
+use App\Message\Message\MailerCommand;
 use App\Repository\Access\AccessRepository;
 use App\Service\Mailer\Mailer;
 use App\Service\Notifier;

+ 2 - 2
src/Message/Handler/OrganizationCreationHandler.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 
 namespace App\Message\Handler;
 
-use App\Message\Command\OrganizationCreationCommand;
+use App\Message\Message\OrganizationCreation;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\Mailer\MailerInterface;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
@@ -26,7 +26,7 @@ class OrganizationCreationHandler
      * @throws TransportExceptionInterface
      * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
      */
-    public function __invoke(OrganizationCreationCommand $organizationCreationCommand): void
+    public function __invoke(OrganizationCreation $organizationCreationCommand): void
     {
         $organizationCreationRequest = $organizationCreationCommand->getOrganizationCreationRequest();
         $mail = ['subject' => '', 'content' => ''];

+ 3 - 3
src/Message/Handler/OrganizationDeletionHandler.php

@@ -4,8 +4,8 @@ declare(strict_types=1);
 
 namespace App\Message\Handler;
 
-use App\Message\Command\OrganizationCreationCommand;
-use App\Message\Command\OrganizationDeletionCommand;
+use App\Message\Message\OrganizationCreation;
+use App\Message\Message\OrganizationDeletion;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\Mailer\MailerInterface;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
@@ -28,7 +28,7 @@ class OrganizationDeletionHandler
      * @throws TransportExceptionInterface
      * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
      */
-    public function __invoke(OrganizationDeletionCommand $organizationDeletionCommand): void
+    public function __invoke(OrganizationDeletion $organizationDeletionCommand): void
     {
         $organizationCreationRequest = $organizationDeletionCommand->getOrganizationDeletionRequest();
         $mail = ['subject' => '', 'content' => ''];

+ 3 - 3
src/Message/Handler/Typo3/Typo3DeleteCommandHandler.php → src/Message/Handler/Typo3/Typo3DeleteHandler.php

@@ -2,12 +2,12 @@
 
 namespace App\Message\Handler\Typo3;
 
-use App\Message\Command\Typo3\Typo3DeleteCommand;
+use App\Message\Message\Typo3\Typo3Delete;
 use App\Service\Typo3\Typo3Service;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
 
 #[AsMessageHandler(priority: 1)]
-class Typo3DeleteCommandHandler
+class Typo3DeleteHandler
 {
     public function __construct(
         private Typo3Service $typo3Service
@@ -17,7 +17,7 @@ class Typo3DeleteCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3DeleteCommand $command): void
+    public function __invoke(Typo3Delete $command): void
     {
         $this->typo3Service->deleteSite($command->getOrganizationId());
     }

+ 3 - 3
src/Message/Handler/Typo3/Typo3UndeleteCommandHandler.php → src/Message/Handler/Typo3/Typo3UndeleteHandler.php

@@ -2,12 +2,12 @@
 
 namespace App\Message\Handler\Typo3;
 
-use App\Message\Command\Typo3\Typo3UndeleteCommand;
+use App\Message\Message\Typo3\Typo3Undelete;
 use App\Service\Typo3\Typo3Service;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
 
 #[AsMessageHandler(priority: 1)]
-class Typo3UndeleteCommandHandler
+class Typo3UndeleteHandler
 {
     public function __construct(
         private Typo3Service $typo3Service
@@ -17,7 +17,7 @@ class Typo3UndeleteCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3UndeleteCommand $command): void
+    public function __invoke(Typo3Undelete $command): void
     {
         $this->typo3Service->undeleteSite($command->getOrganizationId());
     }

+ 3 - 3
src/Message/Handler/Typo3/Typo3UpdateCommandHandler.php → src/Message/Handler/Typo3/Typo3UpdateHandler.php

@@ -2,12 +2,12 @@
 
 namespace App\Message\Handler\Typo3;
 
-use App\Message\Command\Typo3\Typo3UpdateCommand;
+use App\Message\Message\Typo3\Typo3Update;
 use App\Service\Typo3\Typo3Service;
 use Symfony\Component\Messenger\Attribute\AsMessageHandler;
 
 #[AsMessageHandler(priority: 1)]
-class Typo3UpdateCommandHandler
+class Typo3UpdateHandler
 {
     public function __construct(
         private Typo3Service $typo3Service
@@ -17,7 +17,7 @@ class Typo3UpdateCommandHandler
     /**
      * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
      */
-    public function __invoke(Typo3UpdateCommand $command): void
+    public function __invoke(Typo3Update $command): void
     {
         $this->typo3Service->updateSite($command->getOrganizationId());
     }

+ 1 - 1
src/Message/Command/Export.php → src/Message/Message/Export.php

@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command;
+namespace App\Message\Message;
 
 use App\ApiResources\Export\ExportRequest;
 

+ 1 - 1
src/Message/Command/MailerCommand.php → src/Message/Message/MailerCommand.php

@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command;
+namespace App\Message\Message;
 
 use App\Service\Mailer\Model\MailerModelInterface;
 

+ 2 - 2
src/Message/Command/OrganizationCreationCommand.php → src/Message/Message/OrganizationCreation.php

@@ -2,14 +2,14 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command;
+namespace App\Message\Message;
 
 use App\ApiResources\Organization\OrganizationCreationRequest;
 
 /**
  * Transmission d'une requête de création d'organisation au service dédié.
  */
-class OrganizationCreationCommand
+class OrganizationCreation
 {
     public function __construct(
         private OrganizationCreationRequest $organizationCreationRequest

+ 2 - 2
src/Message/Command/OrganizationDeletionCommand.php → src/Message/Message/OrganizationDeletion.php

@@ -2,14 +2,14 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command;
+namespace App\Message\Message;
 
 use App\ApiResources\Organization\OrganizationDeletionRequest;
 
 /**
  * Transmission d'une requête de création d'organisation au service dédié.
  */
-class OrganizationDeletionCommand
+class OrganizationDeletion
 {
     public function __construct(
         private OrganizationDeletionRequest $organizationDeletionRequest

+ 2 - 2
src/Message/Command/Typo3/Typo3DeleteCommand.php → src/Message/Message/Typo3/Typo3Delete.php

@@ -2,12 +2,12 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command\Typo3;
+namespace App\Message\Message\Typo3;
 
 /**
  * Envoi d'une requête Delete à l'api Typo3.
  */
-class Typo3DeleteCommand
+class Typo3Delete
 {
     public function __construct(
         private int $organizationId

+ 2 - 2
src/Message/Command/Typo3/Typo3UndeleteCommand.php → src/Message/Message/Typo3/Typo3Undelete.php

@@ -2,12 +2,12 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command\Typo3;
+namespace App\Message\Message\Typo3;
 
 /**
  * Envoi d'une requête Undelete à l'api Typo3.
  */
-class Typo3UndeleteCommand
+class Typo3Undelete
 {
     public function __construct(
         private int $organizationId

+ 2 - 2
src/Message/Command/Typo3/Typo3UpdateCommand.php → src/Message/Message/Typo3/Typo3Update.php

@@ -2,12 +2,12 @@
 
 declare(strict_types=1);
 
-namespace App\Message\Command\Typo3;
+namespace App\Message\Message\Typo3;
 
 /**
  * Envoi d'une requête Update à l'api Typo3.
  */
-class Typo3UpdateCommand
+class Typo3Update
 {
     public function __construct(
         private int $organizationId

+ 7 - 7
src/Service/OnChange/Organization/OnParametersChange.php

@@ -8,9 +8,9 @@ use App\Entity\Booking\Course;
 use App\Entity\Education\EducationNotationConfig;
 use App\Entity\Organization\Parameters;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
-use App\Message\Command\Typo3\Typo3DeleteCommand;
-use App\Message\Command\Typo3\Typo3UndeleteCommand;
-use App\Message\Command\Typo3\Typo3UpdateCommand;
+use App\Message\Message\Typo3\Typo3Delete;
+use App\Message\Message\Typo3\Typo3Undelete;
+use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Booking\CourseRepository;
 use App\Service\Network\Utils as NetworkUtils;
 use App\Service\OnChange\OnChangeContext;
@@ -86,7 +86,7 @@ class OnParametersChange extends OnChangeDefault
             && $context->previousData()->getCustomDomain() !== $parameters->getCustomDomain()
         ) {
             $this->messageBus->dispatch(
-                new Typo3UpdateCommand($parameters->getOrganization()->getId())
+                new Typo3Update($parameters->getOrganization()->getId())
             );
         }
 
@@ -97,14 +97,14 @@ class OnParametersChange extends OnChangeDefault
         ) {
             if ($parameters->getDesactivateOpentalentSiteWeb()) {
                 $this->messageBus->dispatch(
-                    new Typo3DeleteCommand($parameters->getOrganization()->getId())
+                    new Typo3Delete($parameters->getOrganization()->getId())
                 );
             } else {
                 $this->messageBus->dispatch(
-                    new Typo3UndeleteCommand($parameters->getOrganization()->getId())
+                    new Typo3Undelete($parameters->getOrganization()->getId())
                 );
                 $this->messageBus->dispatch(
-                    new Typo3UpdateCommand($parameters->getOrganization()->getId())
+                    new Typo3Update($parameters->getOrganization()->getId())
                 );
             }
         }

+ 3 - 3
src/Service/Typo3/SubdomainService.php

@@ -4,8 +4,8 @@ namespace App\Service\Typo3;
 
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Subdomain;
-use App\Message\Command\MailerCommand;
-use App\Message\Command\Typo3\Typo3UpdateCommand;
+use App\Message\Message\MailerCommand;
+use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Organization\SubdomainRepository;
 use App\Service\Mailer\Model\SubdomainChangeModel;
@@ -215,7 +215,7 @@ class SubdomainService
     protected function updateTypo3Website(Organization $organization): void
     {
         $this->messageBus->dispatch(
-            new Typo3UpdateCommand($organization->getId())
+            new Typo3Update($organization->getId())
         );
     }
 

+ 1 - 1
src/State/Processor/Export/LicenceCmf/ExportRequestProcessor.php

@@ -10,7 +10,7 @@ use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Export\ExportRequest;
 use App\Entity\Access\Access;
 use App\Entity\Core\File;
-use App\Message\Command\Export;
+use App\Message\Message\Export;
 use App\Service\ServiceIterator\ExporterIterator;
 use Symfony\Bundle\SecurityBundle\Security;
 use Symfony\Component\HttpFoundation\Response;

+ 2 - 2
src/State/Processor/Organization/OrganizationCreationRequestProcessor.php

@@ -8,7 +8,7 @@ use ApiPlatform\Metadata\Operation;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Organization\OrganizationCreationRequest;
-use App\Message\Command\OrganizationCreationCommand;
+use App\Message\Message\OrganizationCreation;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Messenger\MessageBusInterface;
@@ -41,7 +41,7 @@ class OrganizationCreationRequestProcessor implements ProcessorInterface
         if ($organizationCreationRequest->isAsync()) {
             // Send the export request to Messenger (@see App\Message\Handler\OrganizationCreationHandler)
             $this->messageBus->dispatch(
-                new OrganizationCreationCommand($organizationCreationRequest)
+                new OrganizationCreation($organizationCreationRequest)
             );
         } else {
             // For testing purposes only

+ 3 - 3
src/State/Processor/Organization/OrganizationDeletionRequestProcessor.php

@@ -10,8 +10,8 @@ use ApiPlatform\Metadata\Post;
 use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Organization\OrganizationCreationRequest;
 use App\ApiResources\Organization\OrganizationDeletionRequest;
-use App\Message\Command\OrganizationCreationCommand;
-use App\Message\Command\OrganizationDeletionCommand;
+use App\Message\Message\OrganizationCreation;
+use App\Message\Message\OrganizationDeletion;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Messenger\MessageBusInterface;
@@ -44,7 +44,7 @@ class OrganizationDeletionRequestProcessor implements ProcessorInterface
         if ($organizationDeletionRequest->isAsync()) {
             // Send the export request to Messenger (@see App\Message\Handler\OrganizationCreationHandler)
             $this->messageBus->dispatch(
-                new OrganizationDeletionCommand($organizationDeletionRequest)
+                new OrganizationDeletion($organizationDeletionRequest)
             );
         } else {
             // For testing purposes only

+ 11 - 11
tests/Unit/Service/OnChange/Organization/OnParametersChangeTest.php

@@ -11,9 +11,9 @@ use App\Entity\Education\EducationNotationConfig;
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Enum\Education\AdvancedEducationNotationTypeEnum;
-use App\Message\Command\Typo3\Typo3DeleteCommand;
-use App\Message\Command\Typo3\Typo3UndeleteCommand;
-use App\Message\Command\Typo3\Typo3UpdateCommand;
+use App\Message\Message\Typo3\Typo3Delete;
+use App\Message\Message\Typo3\Typo3Undelete;
+use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Booking\CourseRepository;
 use App\Service\Network\Utils as NetworkUtils;
 use App\Service\OnChange\OnChangeContext;
@@ -206,8 +206,8 @@ class OnParametersChangeTest extends TestCase
         $this->messageBus
             ->expects(self::once())
             ->method('dispatch')
-            ->with(self::isInstanceOf(Typo3UpdateCommand::class))
-            ->willReturn(new Envelope(new Typo3UpdateCommand(1)));
+            ->with(self::isInstanceOf(Typo3Update::class))
+            ->willReturn(new Envelope(new Typo3Update(1)));
 
         $previousParameters = $this->getMockBuilder(Parameters::class)->getMock();
         $previousParameters->method('getId')->willReturn(1);
@@ -245,8 +245,8 @@ class OnParametersChangeTest extends TestCase
         $this->messageBus
             ->expects(self::once())
             ->method('dispatch')
-            ->with(self::isInstanceOf(Typo3DeleteCommand::class))
-            ->willReturn(new Envelope(new Typo3DeleteCommand(1)));
+            ->with(self::isInstanceOf(Typo3Delete::class))
+            ->willReturn(new Envelope(new Typo3Delete(1)));
 
         $previousParameters = $this->getMockBuilder(Parameters::class)->getMock();
         $previousParameters->method('getId')->willReturn(1);
@@ -285,11 +285,11 @@ class OnParametersChangeTest extends TestCase
             ->expects(self::exactly(2))
             ->method('dispatch')
             ->willReturnCallback(function ($message) {
-                if ($message instanceof Typo3UndeleteCommand) {
-                    return new Envelope(new Typo3UndeleteCommand(1));
+                if ($message instanceof Typo3Undelete) {
+                    return new Envelope(new Typo3Undelete(1));
                 }
-                if ($message instanceof Typo3UpdateCommand) {
-                    return new Envelope(new Typo3UpdateCommand(1));
+                if ($message instanceof Typo3Update) {
+                    return new Envelope(new Typo3Update(1));
                 }
                 throw new \AssertionError('unexpected message : '.$message::class);
             });

+ 4 - 4
tests/Unit/Service/Typo3/SubdomainServiceTest.php

@@ -7,8 +7,8 @@ use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Entity\Organization\Subdomain;
 use App\Entity\Person\Person;
-use App\Message\Command\MailerCommand;
-use App\Message\Command\Typo3\Typo3UpdateCommand;
+use App\Message\Message\MailerCommand;
+use App\Message\Message\Typo3\Typo3Update;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Organization\SubdomainRepository;
 use App\Service\Mailer\Model\SubdomainChangeModel;
@@ -471,8 +471,8 @@ class SubdomainServiceTest extends TestCase
         $this->messageBus
             ->expects(self::once())
             ->method('dispatch')
-            ->with(self::isInstanceOf(Typo3UpdateCommand::class))
-            ->willReturn(new Envelope(new Typo3UpdateCommand(1)));
+            ->with(self::isInstanceOf(Typo3Update::class))
+            ->willReturn(new Envelope(new Typo3Update(1)));
 
         $subdomainService->updateTypo3Website($organization);
     }