You are here

public function FileUploadForm::validateForm in Ubercart 8.4

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

uc_file/src/Form/FileUploadForm.php, line 148

Class

FileUploadForm
Performs a file upload action.

Namespace

Drupal\uc_file\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $hooks = $this->moduleHandler
    ->getImplementations('uc_file_action');

  // Upload the files and get their objects.
  $temp_files = file_save_upload('upload', [
    'file_validate_extensions' => [],
  ]);
  foreach ($temp_files as $temp_file) {

    // Invoke any implemented hook_uc_file_action('upload_validate', $args).
    foreach ($hooks as $module) {
      $name = $module . '_uc_file_action';
      $name('upload_validate', [
        'file_object' => $temp_file,
        'form_id' => $form_id,
        'form_state' => $form_state,
      ]);
    }
  }

  // Save the uploaded file for later processing.
  $form_state
    ->set('temp_files', $temp_files);
}