You are here

private function Importer::duplicateExisting in Feeds Paragraphs 8

Duplicates an existing paragraph entity.

Parameters

Paragraph $existing: The existing Paragraph entity.

Return value

Paragraph The duplicated entity, or null on failure.

2 calls to Importer::duplicateExisting()
Importer::appendParagraphs in src/Importer.php
Creates and updates new paragraphs entities when needed.
Importer::createParagraphs in src/Importer.php
Creates new Paragraphs entities, and marks others for values changes.

File

src/Importer.php, line 488

Class

Importer

Namespace

Drupal\feeds_para_mapper

Code

private function duplicateExisting($existing) {
  if ($existing
    ->isNew()) {
    $host_info = $existing->host_info;
  }
  else {
    $host_info = array();
    $parent = $existing
      ->getParentEntity();
    $host_info['bundle'] = $existing
      ->getType();
    $host_info['field'] = $existing
      ->get('parent_field_name')
      ->getValue()[0]['value'];
    $host_info['entity'] = $parent;
  }
  return $this
    ->createParagraph($host_info['field'], $host_info['bundle'], $host_info['entity']);
}