Skip to content

Commit 3953f6f

Browse files
authored
fix(state): read provider without request (#5803)
1 parent 46fd899 commit 3953f6f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/State/Provider/ReadProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
5353
return null;
5454
}
5555

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

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

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

9393
return $data;
9494
}

0 commit comments

Comments
 (0)