From fb8d85299a93cf21b05a63f213edcfd7c98fc980 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 27 Sep 2018 09:46:51 +0200 Subject: [PATCH] Fix for service status response (#39) --- src/Jsend/ServiceStatusResponse.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Jsend/ServiceStatusResponse.php b/src/Jsend/ServiceStatusResponse.php index fe1c175..7b801ac 100644 --- a/src/Jsend/ServiceStatusResponse.php +++ b/src/Jsend/ServiceStatusResponse.php @@ -117,20 +117,22 @@ public static function checkServices( $servicesStatus = []; foreach ($servicesClients as $serviceName => $serviceClient) { $serviceName = $serviceClient->getName(); - if (!empty($servicesStatus[$serviceName]) || in_array($serviceName, $whoAsks)) { - $servicesStatus[$serviceName] = StatusEnum::SUCCESS; + $servicesStatus[$serviceName] = !empty($serviceStatus[$serviceName]) ? $serviceStatus[$serviceName] : StatusEnum::SUCCESS; continue; } $serviceStatusResult = ServiceStatusResponse::getServiceStatus($serviceClient, $whoAsks, $headers); $data = $serviceStatusResult->getResponseBody(); - if ($data['status'] !== StatusEnum::SUCCESS) { + if($data['status'] !== StatusEnum::SUCCESS) { $status = StatusEnum::ERROR; } $servicesStatus[$serviceName] = $data['status']; - foreach ($data['data']['services'] as $key => $status) { - $servicesStatus[$key] = $status; + foreach ($data['data']['services'] as $key => $serviceStatus) { + $servicesStatus[$key] = $serviceStatus; + if($serviceStatus !== StatusEnum::SUCCESS) { + $status = StatusEnum::ERROR; + } } } return $servicesStatus;