You are here

public function QuickNodeCloneEntitySettingsForm::submitForm in Quick Node Clone 8

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 ConfigFormBase::submitForm

1 call to QuickNodeCloneEntitySettingsForm::submitForm()
QuickNodeCloneNodeSettingsForm::submitForm in src/Form/QuickNodeCloneNodeSettingsForm.php
Form submission handler.
1 method overrides QuickNodeCloneEntitySettingsForm::submitForm()
QuickNodeCloneNodeSettingsForm::submitForm in src/Form/QuickNodeCloneNodeSettingsForm.php
Form submission handler.

File

src/Form/QuickNodeCloneEntitySettingsForm.php, line 177

Class

QuickNodeCloneEntitySettingsForm
Abstract class to configure how entities are cloned.

Namespace

Drupal\quick_node_clone\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_state
    ->cleanValues();
  $form_values = $form_state
    ->getValues();

  // Build an array of excluded fields for each bundle.
  $bundle_names = [];
  foreach (array_filter($form_values['bundle_names']) as $type) {
    if (!empty(array_filter($form_values[$type]))) {
      $bundle_names[$type] = array_values(array_filter($form_values[$type]));
    }
  }

  // Save config.
  $this
    ->config('quick_node_clone.settings')
    ->set('exclude.' . $this
    ->getEntityTypeId(), $bundle_names)
    ->save();
}