You are here

public function Simplelogin::submitForm in SimpleLogin 8.6

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/Simplelogin.php, line 185
Contains \Drupal\simplelogin\Form\SettingsForm. Simplelogin settings form.

Class

Simplelogin
Defines a form that configure settings.

Namespace

Drupal\simplelogin\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $image_id = isset($values['background_image']) ? $values['background_image'] : '';
  if (!empty($image_id)) {
    $file = File::load($image_id[0]);
    if ($file instanceof File) {
      $file
        ->setPermanent();

      // FILE_STATUS_PERMANENT;
      $file
        ->save();
    }
  }
  $this
    ->config('simplelogin.settings')
    ->set('background_active', $values['background_active'])
    ->set('background_image', $values['background_image'])
    ->set('background_color', $values['background_color'])
    ->set('background_opacity', $values['background_opacity'])
    ->set('wrapper_width', $values['wrapper_width'])
    ->set('unset_active_css', $values['unset_active_css'])
    ->set('unset_css', $values['unset_css'])
    ->save();
  drupal_flush_all_caches();
}