protected SiteSettingsForm::getDatabaseErrors(array $database, $settings_file)
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.
File
- core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php, line 177
Class
- SiteSettingsForm
- Provides a form to configure and rewrite settings.php.
Namespace
Drupal\Core\Installer\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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 = [ '#type' => 'inline_template' , '#template' => '{% trans %}Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.{% endtrans%}{{ errors }}' , '#context' => [ 'errors' => [ '#theme' => 'item_list' , '#items' => $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->renderPlain( $error_message ); } return $form_errors ; } |
Please login to continue.