You are here

public function TamperAddForm::submitForm in Feeds Tamper 8.2

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/TamperAddForm.php, line 101

Class

TamperAddForm
Provides a form to add a tamper plugin to a feed type.

Namespace

Drupal\feeds_tamper\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Support non-javascript browsers.
  if (empty($this->plugin) || $this->plugin
    ->getPluginId() !== $form_state
    ->getValue('tamper_id')) {
    $form_state
      ->setRebuild();
    return;
  }
  $config = $this
    ->prepareConfig($this->sourceField, $form_state);
  $tamper_meta = $this->feedTypeTamperManager
    ->getTamperMeta($this->feedsFeedType);
  $tamper_meta
    ->addTamper($config);
  $this->feedsFeedType
    ->save();
  $this
    ->messenger()
    ->addStatus($this
    ->t('Plugin %plugin_label was successfully added to %source.', [
    '%plugin_label' => $this->plugin
      ->getPluginDefinition()['label'],
    '%source' => $this->sourceField,
  ]));
}