function SiteSettingsForm::getDatabaseErrors
Same name in other branches
- 9 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::getDatabaseErrors()
- 8.9.x core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::getDatabaseErrors()
- 10 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::getDatabaseErrors()
Get any database errors and links them to a form element.
Parameters
array $database: An array of database settings.
string $settings_file: The settings file that contains the database settings.
Return value
array An array of form errors keyed by the element name and parents.
1 call to SiteSettingsForm::getDatabaseErrors()
- SiteSettingsForm::validateForm in core/
lib/ Drupal/ Core/ Installer/ Form/ SiteSettingsForm.php - Form validation handler.
File
-
core/
lib/ Drupal/ Core/ Installer/ Form/ SiteSettingsForm.php, line 182
Class
- SiteSettingsForm
- Provides a form to configure and rewrite settings.php.
Namespace
Drupal\Core\Installer\FormCode
protected function getDatabaseErrors(array $database, $settings_file) {
$errors = install_database_errors($database, $settings_file);
$form_errors = array_filter($errors, function ($value) {
// Errors keyed by something other than an integer already are linked to
// form elements.
return is_int($value);
});
// Find the generic errors.
$errors = array_diff_key($errors, $form_errors);
if (count($errors)) {
$error_message = static::getDatabaseErrorsTemplate($errors);
// These are generic errors, so we do not have any specific key of the
// database connection array to attach them to; therefore, we just put
// them in the error array with standard numeric keys.
$form_errors[$database['driver'] . '][0'] = $this->renderer
->renderInIsolation($error_message);
}
return $form_errors;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.