jad
jad copied to clipboard
Standalone example
Description
Hi Oli, kudos for a job well done! I have a question regarding standalone usage. Let's assume that I have my router that takes Symfony\Component\HttpFoundation\Request and returns Symfony\Component\HttpFoundation\Response. Can you please tell me how can I can achieve something like that:
<?php
use Jad\Jad;
use Jad\Map\AnnotationsMapper;
use Jad\Request\JsonApiRequest;
use Jad\Request\Parameters;
use Jad\Response\JsonApiResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class JsonApiRouter
{
public function __invoke(Request $request): Response
{
$parameters = new Parameters();
$parameters->setArguments($request->query->all());
$mapper = new AnnotationsMapper($this->getEm());
$jsonApiRequest = new JsonApiRequest($request, $parameters);
$jsonApiRequest->setPathPrefix('/json');
$response = new JsonApiResponse($jsonApiRequest, $mapper);
return $response->getRawResponse(); // this is what I miss :)
}
}
Hi, thank you for reaching out, sorry for late reply. This is not available at this time but basically what you want is the the document json encoded I guess. If you are up for it, a PR would be appreciated, otherwise I can look at it later.
Thanx!