|
@@ -0,0 +1,42 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+declare(strict_types=1);
|
|
|
|
|
+
|
|
|
|
|
+namespace App\State\Processor\Organization;
|
|
|
|
|
+
|
|
|
|
|
+use ApiPlatform\Metadata\Delete;
|
|
|
|
|
+use ApiPlatform\Metadata\Operation;
|
|
|
|
|
+use ApiPlatform\State\ProcessorInterface;
|
|
|
|
|
+use App\ApiResources\Organization\OrganizationCreationRequest;
|
|
|
|
|
+use App\Message\Command\OrganizationCreationCommand;
|
|
|
|
|
+use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
+use Symfony\Component\Messenger\MessageBusInterface;
|
|
|
|
|
+
|
|
|
|
|
+class OrganizationCreationRequestProcessor implements ProcessorInterface
|
|
|
|
|
+{
|
|
|
|
|
+ public function __construct(
|
|
|
|
|
+ private MessageBusInterface $messageBus,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
+ * @param mixed[] $uriVariables
|
|
|
|
|
+ * @param mixed[] $context
|
|
|
|
|
+ *
|
|
|
|
|
+ * @throws \Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function process(mixed $organizationCreationRequest, Operation $operation, array $uriVariables = [], array $context = []): OrganizationCreationRequest
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($operation instanceof Delete) {
|
|
|
|
|
+ throw new \RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Send the export request to Messenger (@see App\Message\Handler\OrganizationCreationHandler)
|
|
|
|
|
+ $this->messageBus->dispatch(
|
|
|
|
|
+ new OrganizationCreationCommand($organizationCreationRequest)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ return $organizationCreationRequest;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|