You are here

public function TamperListForm::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/TamperListForm.php, line 268

Class

TamperListForm
Provides a form to manage tamper plugins for a feed type.

Namespace

Drupal\feeds_tamper\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($this->groupedMappings as $source => $targets) {
    if ($tampers = $form_state
      ->getValue($source)) {
      foreach ($tampers as $tamper_uuid => $values) {

        // @todo Implement enabled.
        $tamper_meta = $this->feedTypeTamperManager
          ->getTamperMeta($this->feedsFeedType);
        $tamper = $tamper_meta
          ->getTamper($tamper_uuid);
        $tamper_meta
          ->setTamperConfig($tamper_uuid, array_merge($tamper
          ->getConfiguration(), [
          'weight' => $values['weight'],
        ]));
      }
    }
  }
  $this->feedsFeedType
    ->save();
  $this
    ->messenger()
    ->addStatus($this
    ->t('Your changes have been saved.'));
}