You are here

public function UploadFetcherForm::validateConfigurationForm in Feeds 8.3

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides ExternalPluginFormBase::validateConfigurationForm

File

src/Feeds/Fetcher/Form/UploadFetcherForm.php, line 82

Class

UploadFetcherForm
The configuration form for the upload fetcher.

Namespace

Drupal\feeds\Feeds\Fetcher\Form

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $values =& $form_state
    ->getValues();
  $values['allowed_extensions'] = preg_replace('/\\s+/', ' ', trim($values['allowed_extensions']));

  // Ensure that the upload directory exists.
  if (!empty($form['directory']) && !$this->fileSystem
    ->prepareDirectory($values['directory'], FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
    $form_state
      ->setError($form['directory'], $this
      ->t('The chosen directory does not exist and attempts to create it failed.'));
  }
}