|
|
@@ -1,49 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-declare(strict_types=1);
|
|
|
-
|
|
|
-namespace App\State\Provider\HelloAsso;
|
|
|
-
|
|
|
-use ApiPlatform\Metadata\GetCollection;
|
|
|
-use ApiPlatform\Metadata\Operation;
|
|
|
-use ApiPlatform\State\ProviderInterface;
|
|
|
-use App\ApiResources\HelloAsso\CallbackForwarding;
|
|
|
-use App\Service\HelloAsso\ConnectionService;
|
|
|
-use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
|
-use Symfony\Component\HttpFoundation\RequestStack;
|
|
|
-use Symfony\Component\HttpFoundation\Response;
|
|
|
-
|
|
|
-/**
|
|
|
- * Provider pour la ressource CallbackForwarding HelloAsso.
|
|
|
- */
|
|
|
-final class CallbackForwardingProvider implements ProviderInterface
|
|
|
-{
|
|
|
- public function __construct(
|
|
|
- private ConnectionService $connectionService,
|
|
|
- private RequestStack $requestStack,
|
|
|
- ) {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param mixed[] $uriVariables
|
|
|
- * @param mixed[] $context
|
|
|
- *
|
|
|
- * @throws \Exception
|
|
|
- */
|
|
|
- public function provide(Operation $operation, array $uriVariables = [], array $context = []): RedirectResponse
|
|
|
- {
|
|
|
- if ($operation instanceof GetCollection) {
|
|
|
- throw new \RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED);
|
|
|
- }
|
|
|
-
|
|
|
- $request = $this->requestStack->getCurrentRequest();
|
|
|
- if (!$request) {
|
|
|
- throw new \RuntimeException('No current request available');
|
|
|
- }
|
|
|
-
|
|
|
- $queryParameters = $request->query->all();
|
|
|
- $redirectUrl = $this->connectionService->forwardCallbackTo($queryParameters);
|
|
|
-
|
|
|
- return new RedirectResponse($redirectUrl);
|
|
|
- }
|
|
|
-}
|