Skip to content

Commit

Permalink
Merge pull request #610 from CommonGateway/feature/KTB-8/fix-events-w…
Browse files Browse the repository at this point in the history
…ithout-response

Fix EndpointService event response
  • Loading branch information
bbrands02 authored Oct 9, 2024
2 parents 3a0a32f + 56001cc commit 4ec46a6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/Service/EndpointService.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,28 @@ public function handleRequest(Request $request): Response
foreach ($endpoint->getThrows() as $throw) {
$event = new ActionEvent('commongateway.action.event', $parameters, $throw);
$this->eventDispatcher->dispatch($event, 'commongateway.action.event');
$parameters['response'] = $event->getData()['response'];

// If the response is set by the event, we assign it.
if (isset($event->getData()['response']) === true) {
$response = $event->getData()['response'];
}
}

$parameters['response'] = $event->getData()['response'];
}
// If the response is set by any earlier event, we return it.
if (isset($response) === true) {
return $response;
}
}//end if

// If the response is set by any way else than an event, we return it.
if (isset($parameters['response']) === true) {
return $parameters['response'];
return$parameters['response'];
}

$this->logger->error('No proxy, schema or events could be established for this endpoint');
$errorMessage = 'No proxy or schema could be established for this endpoint. Events might have been triggered but if so, no response has been returned.';

throw new Exception('No proxy, schema or events could be established for this endpoint');
$this->logger->error($errorMessage);
throw new Exception($errorMessage);

}//end handleRequest()

Expand Down

0 comments on commit 4ec46a6

Please sign in to comment.