You are here

public function AuditFilesMergeFileReferences::submissionHandlerMergeRecord in Audit Files 8.2

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

Submit form.

File

src/Form/AuditFilesMergeFileReferences.php, line 398

Class

AuditFilesMergeFileReferences
Form for merge file references.

Namespace

Drupal\auditfiles\Form

Code

public function submissionHandlerMergeRecord(array &$form, FormStateInterface $form_state) {
  $this->configFactoryStorage
    ->getEditable('auditfiles.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)) {
      $this
        ->messenger()
        ->addStatus($this
        ->t('At least one file name must be selected in order to merge the file IDs. No changes were made.'));
    }
  }
}