Skip to content

Commit

Permalink
fix(state): read provider without request (#5803)
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka authored Sep 8, 2023
1 parent 46fd899 commit 3953f6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/State/Provider/ReadProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
return null;
}

if (null === $filters = $request->attributes->get('_api_filters')) {
if (null === $filters = $request?->attributes->get('_api_filters')) {
$queryString = RequestParser::getQueryString($request);
$filters = $queryString ? RequestParser::parseRequestParams($queryString) : null;
}
Expand All @@ -62,7 +62,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$context['filters'] = $filters;
}

if ($this->serializerContextBuilder) {
if ($this->serializerContextBuilder && $request) {
// Builtin data providers are able to use the serialization context to automatically add join clauses
$context += $this->serializerContextBuilder->createFromRequest($request, true, [
'resource_class' => $operation->getClass(),
Expand All @@ -87,8 +87,8 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
throw new NotFoundHttpException('Not Found');
}

$request->attributes->set('data', $data);
$request->attributes->set('previous_data', $this->clone($data));
$request?->attributes->set('data', $data);
$request?->attributes->set('previous_data', $this->clone($data));

return $data;
}
Expand Down

0 comments on commit 3953f6f

Please sign in to comment.