You are here

public function AuditFilesMergeFileReferences::submissionHandlerMergeRecord in Audit Files 8

Same name and namespace in other branches
  1. 8.2 src/Form/AuditFilesMergeFileReferences.php \Drupal\auditfiles\Form\AuditFilesMergeFileReferences::submissionHandlerMergeRecord()

Submit form.

File

src/Form/AuditFilesMergeFileReferences.php, line 308

Class

AuditFilesMergeFileReferences

Namespace

Drupal\auditfiles\Form

Code

public function submissionHandlerMergeRecord(array &$form, FormStateInterface $form_state) {
  \Drupal::configFactory()
    ->getEditable('auditfiles_config.settings')
    ->set('auditfiles_merge_file_references_show_single_file_names', $form_state
    ->getValue('auditfiles_merge_file_references_show_single_file_names'))
    ->save();
  if (!empty($form_state
    ->getValue('files'))) {
    foreach ($form_state
      ->getValue('files') as $file_id) {
      if (!empty($file_id)) {
        $storage = [
          'files' => $form_state
            ->getValue('files'),
          'confirm' => TRUE,
          'stage' => 'preconfirm',
        ];
        $form_state
          ->setStorage($storage);
        $form_state
          ->setRebuild();
      }
    }
    if (!isset($storage)) {
      drupal_set_message($this
        ->t('At least one file name must be selected in order to merge the file IDs. No changes were made.'), 'error');
    }
  }
}