Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone example #45

Open
archudzik opened this issue Sep 28, 2021 · 1 comment
Open

Standalone example #45

archudzik opened this issue Sep 28, 2021 · 1 comment

Comments

@archudzik
Copy link

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 :)
    }
}
@oligus
Copy link
Owner

oligus commented Oct 7, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants