Filter JSON Result against RQL Query String with PHP

I’ve an Symfony 4 Api Project which has to filter their Result by an RQL String.

Request:

localhost/api?q=altProductId=in=(456)

The altProductId is not part of database. It is added by the controller.
The Output is a JSONResponse like:

Response:

{
    "data": [
        {"altProductId": 123},
        {"altProductId": 456},
        {"altProductId": 789}
    ]
}

And it should be for the above request:

{
    "data": [
        {"altProductId": 456}
    ]
}

I’ve already tried to parse the Query with GravitonRqlParser, but do not know how to filter the Json Result with this or another way.

Can someone help?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *