|
|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace App\State\Provider\HelloAsso;
|
|
|
|
|
|
+use ApiPlatform\Metadata\Get;
|
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
|
use ApiPlatform\State\ProviderInterface;
|
|
|
@@ -35,19 +36,20 @@ final class EventFormProvider implements ProviderInterface
|
|
|
*/
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ArrayCollection | EventForm
|
|
|
{
|
|
|
+ if ($operation instanceof Get && isset($uriVariables['eventId'])) {
|
|
|
+ // This is a public endpoint
|
|
|
+ return $this->helloAssoService->getHelloAssoEventFormByEventId($uriVariables['eventId']);
|
|
|
+ }
|
|
|
+
|
|
|
/** @var Access $access */
|
|
|
$access = $this->security->getUser();
|
|
|
-
|
|
|
$organizationId = $access->getOrganization()->getId();
|
|
|
|
|
|
if ($operation instanceof GetCollection) {
|
|
|
$forms = $this->helloAssoService->getHelloAssoEventForms($organizationId);
|
|
|
-
|
|
|
return new ArrayCollection($forms);
|
|
|
- } else if (isset($uriVariables['eventId'])) {
|
|
|
- return $this->helloAssoService->getHelloAssoEventFormByEventId($organizationId, $uriVariables['eventId']);
|
|
|
- } else {
|
|
|
- return $this->helloAssoService->getHelloAssoEventForm($organizationId, $uriVariables['slug']);
|
|
|
}
|
|
|
+
|
|
|
+ return $this->helloAssoService->getHelloAssoEventForm($organizationId, $uriVariables['slug']);
|
|
|
}
|
|
|
}
|