You are here

protected function WebformEntitySettingsGeneralForm::copyFormValuesToEntity in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/EntitySettings/WebformEntitySettingsGeneralForm.php \Drupal\webform\EntitySettings\WebformEntitySettingsGeneralForm::copyFormValuesToEntity()

Copies top-level form values to entity properties.

This should not change existing entity properties that are not being edited by this form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

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

Overrides EntityForm::copyFormValuesToEntity

File

src/EntitySettings/WebformEntitySettingsGeneralForm.php, line 515

Class

WebformEntitySettingsGeneralForm
Webform general settings.

Namespace

Drupal\webform\EntitySettings

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if ($this->entity instanceof EntityWithPluginCollectionInterface) {

    // Do not manually update values represented by plugin collections.
    $values = array_diff_key($values, $this->entity
      ->getPluginCollections());
  }

  // Do not manually update third party settings.
  // @see \Drupal\webform\EntitySettings\WebformEntitySettingsGeneralForm::save
  unset($values['third_party_settings']);
  foreach ($values as $key => $value) {
    $entity
      ->set($key, $value);
  }
}