try { $connection =
$this->
getConnection($database);
} catch (\Exception
$e) { $msg =
$this->
t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>',
['%error' =>
$e->
getMessage()]);
$this->errors
[$error_key] =
$msg;
} } // Get the Drupal version of the source database so it can be validated.
if (!
$this->errors
) { $version =
(string) $this->
getLegacyDrupalVersion($connection);
if (!
$version) { $this->errors
[$error_key] =
$this->
t('Source database does not contain a recognizable Drupal version.'
);
} elseif ($version !==
(string) $form_state->
getValue('version'
)) { $this->errors
['version'
] =
$this->
t('Source database is Drupal version @version but version @selected was selected.',
[ '@version' =>
$version,
'@selected' =>
$form_state->
getValue('version'
),
]);
} }