You are here

public function AsyncMetatagFirehose::extractFormValues in Metatag Asynchronous Widget 1.0.x

File

src/Plugin/Field/FieldWidget/AsyncMetatagFirehose.php, line 51

Class

AsyncMetatagFirehose
Asynchronous widget for the Metatag field.

Namespace

Drupal\metatag_async_widget\Plugin\Field\FieldWidget

Code

public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) {
  $field_name = $this->fieldDefinition
    ->getName();
  $path = array_merge($form['#parents'], [
    $field_name,
  ]);
  $values = NestedArray::getValue($form_state
    ->getValues(), array_merge($path, [
    0,
  ]));

  // We don't want to override saved meta tags settings if the meta tags
  // fields were not present.
  if (!empty($values) && count($values) === 1 && isset($values['metatag_async_widget_customize_meta_tags'])) {
    NestedArray::unsetValue($form_state
      ->getValues(), $path);
    return;
  }
  parent::extractFormValues($items, $form, $form_state);
}