function SiteConfigureForm::submitForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php \Drupal\Core\Installer\Form\SiteConfigureForm::submitForm()
  2. 10 core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php \Drupal\Core\Installer\Form\SiteConfigureForm::submitForm()
  3. 11.x core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php \Drupal\Core\Installer\Form\SiteConfigureForm::submitForm()

Overrides ConfigFormBase::submitForm

File

core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php, line 275

Class

SiteConfigureForm
Provides the site configuration form.

Namespace

Drupal\Core\Installer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    global $install_state;
    if (empty($install_state['config_install_path'])) {
        $this->config('system.site')
            ->set('name', (string) $form_state->getValue('site_name'))
            ->set('mail', (string) $form_state->getValue('site_mail'))
            ->save(TRUE);
        $this->config('system.date')
            ->set('timezone.default', (string) $form_state->getValue('date_default_timezone'))
            ->set('country.default', (string) $form_state->getValue('site_default_country'))
            ->save(TRUE);
    }
    $account_values = $form_state->getValue('account');
    // Enable update.module if this option was selected.
    $update_status_module = $form_state->getValue('enable_update_status_module');
    if (empty($install_state['config_install_path']) && $update_status_module) {
        $this->moduleInstaller
            ->install([
            'update',
        ]);
        // Add the site maintenance account's email address to the list of
        // addresses to be notified when updates are available, if selected.
        $email_update_status_emails = $form_state->getValue('enable_update_status_emails');
        if ($email_update_status_emails) {
            // Reset the configuration factory so it is updated with the new module.
            $this->resetConfigFactory();
            $this->config('update.settings')
                ->set('notification.emails', [
                $account_values['mail'],
            ])
                ->save(TRUE);
        }
    }
    // We precreated user 1 with placeholder values. Let's save the real values.
    $account = $this->userStorage
        ->load(1);
    $account->init = $account->mail = $account_values['mail'];
    $account->roles = $account->getRoles();
    $account->activate();
    $account->timezone = $form_state->getValue('date_default_timezone');
    $account->pass = $account_values['pass'];
    $account->name = $account_values['name'];
    $account->save();
    // Record when this install ran.
    $this->state
        ->set('install_time', $_SERVER['REQUEST_TIME']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.