You are here

public function FeedsFileFetcher::configForm in Feeds 8.2

Overrides parent::configForm().

Overrides FeedsConfigurable::configForm

File

lib/Drupal/feeds/Plugin/feeds/fetcher/FeedsFileFetcher.php, line 216
Home of the FeedsFileFetcher and related classes.

Class

FeedsFileFetcher
Defines a file fetcher.

Namespace

Drupal\feeds\Plugin\feeds\fetcher

Code

public function configForm(&$form_state) {
  $form = array();
  $form['allowed_extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Allowed file extensions'),
    '#description' => t('Allowed file extensions for upload.'),
    '#default_value' => $this->config['allowed_extensions'],
  );
  $form['direct'] = array(
    '#type' => 'checkbox',
    '#title' => t('Supply path to file or directory directly'),
    '#description' => t('For experts. Lets users specify a path to a file <em>or a directory of files</em> directly,
        instead of a file upload through the browser. This is useful when the files that need to be imported
        are already on the server.'),
    '#default_value' => $this->config['direct'],
  );
  $form['directory'] = array(
    '#type' => 'textfield',
    '#title' => t('Upload directory'),
    '#description' => t('Directory where uploaded files get stored. Prefix the path with a scheme. Available schemes: @schemes.', array(
      '@schemes' => implode(', ', $this
        ->getSchemes()),
    )),
    '#default_value' => $this->config['directory'],
    '#states' => array(
      'visible' => array(
        ':input[name="direct"]' => array(
          'checked' => FALSE,
        ),
      ),
      'required' => array(
        ':input[name="direct"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  if ($options = $this
    ->getSchemeOptions()) {
    $form['allowed_schemes'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Allowed schemes'),
      '#default_value' => $this->config['allowed_schemes'],
      '#options' => $options,
      '#description' => t('Select the schemes you want to allow for direct upload.'),
      '#states' => array(
        'visible' => array(
          ':input[name="direct"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
  }
  return $form;
}