From 71432d9b2127534c2e918217dec15ff8a3afe3cb Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Thu, 19 Dec 2024 12:43:17 +0100 Subject: [PATCH] Add match strategy api resource --- .../Matchfunding/MatchStrategyApiResource.php | 20 ++++++++ .../MatchStrategyStateProvider.php | 47 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/ApiResource/Matchfunding/MatchStrategyApiResource.php create mode 100644 src/State/Matchfunding/MatchStrategyStateProvider.php diff --git a/src/ApiResource/Matchfunding/MatchStrategyApiResource.php b/src/ApiResource/Matchfunding/MatchStrategyApiResource.php new file mode 100644 index 0000000..6e9399a --- /dev/null +++ b/src/ApiResource/Matchfunding/MatchStrategyApiResource.php @@ -0,0 +1,20 @@ +matchStrategyLocator->get($uriVariables['name']); + + return $this->getApiResource($strategy); + } catch (MatchStrategyNotFoundException $e) { + return null; + } + } + + $strategies = $this->matchStrategyLocator->getAll(); + + $resources = []; + foreach ($strategies as $strategy) { + $resources[] = $this->getApiResource($strategy); + } + + return $resources; + } + + private function getApiResource(MatchStrategyInterface $strategy): MatchStrategyApiResource + { + $resource = new MatchStrategyApiResource(); + $resource->name = $strategy::getName(); + + return $resource; + } +}