function FileExampleSubmitHandlerHelper::handleFileExists

Submit handler to check existence of a file.

File

modules/file_example/src/FileExampleSubmitHandlerHelper.php, line 371

Class

FileExampleSubmitHandlerHelper
A submit handler helper class for the file_example module.

Namespace

Drupal\file_example

Code

public function handleFileExists(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state->getValues();
  $uri = $form_values['fileops_file'];
  if (is_file($uri)) {
    $this->messenger
      ->addMessage($this->t('The file %uri exists.', [
      '%uri' => $uri,
    ]));
  }
  else {
    $this->messenger
      ->addMessage($this->t('The file %uri does not exist.', [
      '%uri' => $uri,
    ]));
  }
}