function SiteSettingsForm::submitForm
Same name in other branches
- 9 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::submitForm()
- 10 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::submitForm()
- 11.x core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::submitForm()
Overrides FormInterface::submitForm
File
-
core/
lib/ Drupal/ Core/ Installer/ Form/ SiteSettingsForm.php, line 233
Class
- SiteSettingsForm
- Provides a form to configure and rewrite settings.php.
Namespace
Drupal\Core\Installer\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
global $install_state;
// Update global settings array and save.
$settings = [];
$database = $form_state->get('database');
$settings['databases']['default']['default'] = (object) [
'value' => $database,
'required' => TRUE,
];
$settings['settings']['hash_salt'] = (object) [
'value' => Crypt::randomBytesBase64(55),
'required' => TRUE,
];
// If settings.php does not contain a config sync directory name we need to
// configure one.
if (empty(Settings::get('config_sync_directory'))) {
if (empty($install_state['config_install_path'])) {
// Add a randomized config directory name to settings.php
$config_sync_directory = $this->createRandomConfigDirectory();
}
else {
// Install profiles can contain a config sync directory. If they do,
// 'config_install_path' is a path to the directory.
$config_sync_directory = $install_state['config_install_path'];
}
$settings['settings']['config_sync_directory'] = (object) [
'value' => $config_sync_directory,
'required' => TRUE,
];
}
drupal_rewrite_settings($settings);
// Indicate that the settings file has been verified, and check the database
// for the last completed task, now that we have a valid connection. This
// last step is important since we want to trigger an error if the new
// database already has Drupal installed.
$install_state['settings_verified'] = TRUE;
$install_state['config_verified'] = TRUE;
$install_state['database_verified'] = TRUE;
$install_state['completed_task'] = install_verify_completed_task();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.