Skip to content

Commit

Permalink
Fix undefined variable results
Browse files Browse the repository at this point in the history
  • Loading branch information
smavri-axess committed Jun 6, 2024
1 parent 0512067 commit 44b692d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Plugin/GraphQL/Fields/SearchAPISearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,25 @@ public function resolveValues($value, array $args, ResolveContext $context, Reso
// Execute search.
try {
$results = $this->query->execute();

// Get search response from results.
$search_response = $this->getSearchResponse($results);

// Add the result count to the response.
$search_response['result_count'] = $results->getResultCount();

// Set response type.
$search_response['type'] = 'SearchAPIResult';
}
// Handle error, check exception type -> SearchApiException ?
// Handle error, check exception type -> SearchApiException ?
catch (\Exception $exception) {
$this->logger->get('graphql_search_api')->error($exception->getMessage());
$search_response = [
'result_count' => 0,
'type' => 'SearchAPIResult',
];
}

// Get search response from results.
$search_response = $this->getSearchResponse($results);

// Add the result count to the response.
$search_response['result_count'] = $results->getResultCount();

// Set response type.
$search_response['type'] = 'SearchAPIResult';

yield $search_response;

}
Expand Down

0 comments on commit 44b692d

Please sign in to comment.