You are here

protected function CslStyleFileForm::extractFile in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x src/Form/CslStyleFileForm.php \Drupal\bibcite\Form\CslStyleFileForm::extractFile()

Extract valid file from request.

Return value

null|\Symfony\Component\HttpFoundation\File\UploadedFile Uploaded file or NULL if file not uploaded.

1 call to CslStyleFileForm::extractFile()
CslStyleFileForm::validateForm in src/Form/CslStyleFileForm.php
Form validation handler.

File

src/Form/CslStyleFileForm.php, line 59

Class

CslStyleFileForm
Form for installing bibcite_csl_style entity from file.

Namespace

Drupal\bibcite\Form

Code

protected function extractFile() {
  $all_files = $this
    ->getRequest()->files
    ->get('files', []);
  if (!empty($all_files['file'])) {

    /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
    $file = $all_files['file'];
    if ($file
      ->isValid()) {
      return $file;
    }
  }
  return NULL;
}