public static function SettingsHelper::pingUri in Acquia Lift Connector 8.4
Same name and namespace in other branches
- 8.3 src/Service/Helper/SettingsHelper.php \Drupal\acquia_lift\Service\Helper\SettingsHelper::pingUri()
Ping URI.
Parameters
string $base_uri: Base URI.
string $path: Path to "ping" end point.
Return value
array Returns 'statusCode' and 'reasonPhrase' of the response.
2 calls to SettingsHelper::pingUri()
- AdminSettingsForm::checkConnection in src/
Form/ AdminSettingsForm.php - Check URL's connection.
- SettingsHelperTest::testPingUri in tests/
src/ Unit/ Service/ Helper/ SettingsHelperTest.php - Tests the pingUri() method.
File
- src/
Service/ Helper/ SettingsHelper.php, line 187
Class
- SettingsHelper
- Defines the Settings Helper class.
Namespace
Drupal\acquia_lift\Service\HelperCode
public static function pingUri($base_uri, $path) {
/** @var \Drupal\Core\Http\ClientFactory $clientFactory */
$clientFactory = \Drupal::service('http_client_factory');
$client = $clientFactory
->fromOptions([
'base_uri' => $base_uri,
]);
try {
$response = $client
->get($path, [
'http_errors' => false,
]);
} catch (RequestException $e) {
return [];
}
return [
'statusCode' => $response
->getStatusCode(),
'reasonPhrase' => $response
->getReasonPhrase(),
];
}