You are here

public function BackupDatabaseSettingsForm::validateForm in Backup Database 8

Form validation 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 FormBase::validateForm

File

src/Form/BackupDatabaseSettingsForm.php, line 206
Contains \Drupal\backup_db\Form\BackupDatabaseSettingsForm.

Class

BackupDatabaseSettingsForm
BackupDatabaseSettingsForm class.

Namespace

Drupal\backup_db\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!PrivateStream::basePath()) {

    // if value is private and not set.
    if (strpos($form_state
      ->getValue('private'), '//private') !== FALSE) {
      $form_state
        ->setErrorByName('private', $this
        ->t('Private directory location not set in settings.php.'));
    }
    else {

      // Warn user that it should be private.
      drupal_set_message(t('Private directory is not set and should be used for backup storage.'), 'warning');
    }
  }
}