Example #1
0
/**
 * Form API submit for install_settings form.
 */
function install_settings_form_submit($form, &$form_state)
{
    global $install_state;
    $database = array_intersect_key($form_state['values']['_database'], array_flip(array('driver', 'database', 'username', 'password', 'host', 'port')));
    // Update global settings array and save
    $settings['databases'] = array('value' => array('default' => array('default' => $database)), 'required' => TRUE);
    $settings['db_prefix'] = array('value' => $form_state['values']['db_prefix'], '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['completed_task'] = install_verify_completed_task();
}
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     global $install_state;
     // Update global settings array and save.
     $settings = array();
     $database = $form_state->get('database');
     $settings['databases']['default']['default'] = (object) array('value' => $database, 'required' => TRUE);
     $settings['settings']['hash_salt'] = (object) array('value' => Crypt::randomBytesBase64(55), 'required' => TRUE);
     // Remember the profile which was used.
     $settings['settings']['install_profile'] = (object) array('value' => $install_state['parameters']['profile'], 'required' => TRUE);
     drupal_rewrite_settings($settings);
     // Add the config directories to settings.php.
     drupal_install_config_directories();
     // 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();
 }