Skip to content

Commit

Permalink
Merge pull request #1565 from ConductionNL/feature/MF-46/klanten
Browse files Browse the repository at this point in the history
added custom endpoint
  • Loading branch information
smisidjan authored Oct 3, 2023
2 parents 5781d8c + c017f08 commit 3b17e74
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions api/src/Controller/ZZController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Service\ProcessingLogService;
use CommonGateway\CoreBundle\Service\EndpointService;
use CommonGateway\CoreBundle\Service\RequestService;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -31,13 +32,13 @@ class ZZController extends AbstractController
* @Route("/admin/objects")
* @Route("/admin/objects/{id}", requirements={"path" = ".+"})
*
* @param string|null $path
* @param Request $request
* @param string|null $id
* @param Request $request
* @param SerializerInterface $serializer
* @param HandlerService $handlerService
* @param RequestService $requestService
* @param RequestService $requestService
*
* @return Response
* @throws Exception
*/
public function objectAction(
?string $id,
Expand All @@ -57,22 +58,35 @@ public function objectAction(
}

/**
* This function dynamicly handles the api endpoints.
* @TODO This function needs to be more dynamic: /{item}/api/{path}.
* This function dynamically handles the custom endpoints.
*
* @Route("/api/{path}", name="dynamic_route", requirements={"path" = ".+"})
* @Route("/klanten/api/{path}", name="dynamic_route_second", requirements={"path" = ".+"})
*
* @param string|null $path
* @param Request $request
* @param DocumentService $documentService
* @param HandlerService $handlerService
* @param SerializerInterface $serializer
* @param LogService $logService
* @param ProcessingLogService $processingLogService
* @param RequestService $requestService
* @param string|null $path
* @param Request $request
* @param EndpointService $endpointService
* @return Response
* @throws Exception
*/
public function dynamicCustomAction(
?string $path,
Request $request,
EndpointService $endpointService
): Response {
return $endpointService->handleRequest($request);
}

/**
* This function dynamically handles the api endpoints.
*
* @throws GatewayException
* @Route("/api/{path}", name="dynamic_route", requirements={"path" = ".+"})
*
* @param string|null $path
* @param Request $request
* @param EndpointService $endpointService
* @return Response
* @throws Exception
*/
public function dynamicAction(
?string $path,
Expand Down Expand Up @@ -101,7 +115,7 @@ private function getParametersFromRequest(?array $parameters = [], ?Request $req

try {
$parameters['body'] = $request->toArray();
} catch (\Exception $exception) {
} catch (Exception $exception) {
}

$parameters['crude_body'] = $request->getContent();
Expand Down

0 comments on commit 3b17e74

Please sign in to comment.