Code Duplication    Length = 6-8 lines in 2 locations

src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php 2 locations

@@ 392-397 (lines=6) @@
389
    // entities are added or by one of the "Remove" buttons. Depending on that
390
    // we need to figure out where root of the widget is in the form structure
391
    // and use this information to return correct part of the form.
392
    if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') {
393
      $parents = array_slice($trigger['#array_parents'], 0, -1);
394
    }
395
    elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) {
396
      $parents = array_slice($trigger['#array_parents'], 0, -static::$deleteDepth);
397
    }
398
399
    return NestedArray::getValue($form, $parents);
400
  }
@@ 622-629 (lines=8) @@
619
    if ($is_relevant_submit) {
620
      // Submit was triggered by hidden "target_id" element when entities were
621
      // added via entity browser.
622
      if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') {
623
        $parents = $trigger['#parents'];
624
      }
625
      // Submit was triggered by one of the "Remove" buttons. We need to walk
626
      // few levels up to read value of "target_id" element.
627
      elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) {
628
        $parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']);
629
      }
630
631
      if (isset($parents) && $value = $form_state->getValue($parents)) {
632
        $entities = EntityBrowserElement::processEntityIds($value);