private function AdminSettingsForm::checkConnection in Acquia Lift Connector 8.3
Same name and namespace in other branches
- 8.4 src/Form/AdminSettingsForm.php \Drupal\acquia_lift\Form\AdminSettingsForm::checkConnection()
Check URL's connection.
Parameters
string $name: Name of the service.
string $base_uri: Base URI.
string $path: Path to "ping" end point.
integer $expected_status_code: Expected status code.
1 call to AdminSettingsForm::checkConnection()
- AdminSettingsForm::setCredentialValues in src/
Form/ AdminSettingsForm.php - Set credential values.
File
- src/
Form/ AdminSettingsForm.php, line 582
Class
- AdminSettingsForm
- Defines a form that configures settings.
Namespace
Drupal\acquia_lift\FormCode
private function checkConnection($name, $base_uri, $path, $expected_status_code = 200) {
$responseInfo = SettingsHelper::pingUri($base_uri, $path);
if (empty($responseInfo)) {
$this
->setFormMessage(t('Acquia Lift module could not reach the specified :name URL.', [
':name' => $name,
]), 'error');
return;
}
if ($responseInfo['statusCode'] !== $expected_status_code) {
$this
->setFormMessage(t('Acquia Lift module has successfully connected to :name URL, but received status code ":statusCode" with the reason ":reasonPhrase".', [
':name' => $name,
':statusCode' => $responseInfo['statusCode'],
':reasonPhrase' => $responseInfo['reasonPhrase'],
]), 'error');
}
}