jsonapi-bundle
jsonapi-bundle copied to clipboard
Bundle doesn't work with batch/subrequests
We wanted to create a /batch route by using the HttpKernel:
foreach($requests as $request) {
// ...
$req = Request::create(
$request['relative_url'],
$request['method'],
$options
);
$response = $kernel->handle($req);
}
However, since the ResourceCollection service (and probably others like JsonApi) sets the request on construction, it doesn't work with follow up requests:
/**
* ResourceCollection constructor.
*/
public function __construct(RequestStack $requestStack, FinderCollection $finderCollection, Paginator $paginator, FieldManager $fieldManager)
{
$this->request = $requestStack->getCurrentRequest();
// ...
}
It will handle the same request over and over again.