You are here

class CsvParserFeedForm in Feeds 8.3

Provides a form on the feed edit page for the CsvParser.

Hierarchy

Expanded class hierarchy of CsvParserFeedForm

1 file declares its use of CsvParserFeedForm
CsvParserFeedFormTest.php in tests/src/Unit/Feeds/Parser/Form/CsvParserFeedFormTest.php

File

src/Feeds/Parser/Form/CsvParserFeedForm.php, line 12

Namespace

Drupal\feeds\Feeds\Parser\Form
View source
class CsvParserFeedForm extends ExternalPluginFormBase {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
    $feed_config = $feed
      ->getConfigurationFor($this->plugin);
    $form['delimiter'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Delimiter'),
      '#description' => $this
        ->t('The character that delimits fields in the CSV file.'),
      '#options' => [
        ',' => ',',
        ';' => ';',
        'TAB' => 'TAB',
        '|' => '|',
        '+' => '+',
      ],
      '#default_value' => $feed_config['delimiter'],
    ];
    $form['no_headers'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('No Headers'),
      '#description' => $this
        ->t("Check if the imported CSV file does not start with a header row. If checked, mapping sources must be named '0', '1', '2' etc."),
      '#default_value' => $feed_config['no_headers'],
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
    $feed
      ->setConfigurationFor($this->plugin, $form_state
      ->getValues());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CsvParserFeedForm::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm
CsvParserFeedForm::submitConfigurationForm public function Form submission handler. Overrides ExternalPluginFormBase::submitConfigurationForm
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
ExternalPluginFormBase::$plugin protected property The Feeds plugin.
ExternalPluginFormBase::setPlugin public function Sets the plugin for this object. Overrides PluginAwareInterface::setPlugin
ExternalPluginFormBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm 5
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.