You are here

private function Importer::createParents in Feeds Paragraphs 8

Creates a paragraph entity and its parents entities.

Parameters

object $parent: The entity that is being edited or created.

Return value

EntityInterface The created paragraph entity.

1 call to Importer::createParents()
Importer::createParagraphs in src/Importer.php
Creates new Paragraphs entities, and marks others for values changes.

File

src/Importer.php, line 454

Class

Importer

Namespace

Drupal\feeds_para_mapper

Code

private function createParents($parent) {
  $parents = $this->targetInfo->path;
  $or_count = count($parents);
  $p = $this
    ->removeExistingParents($parents);
  $parents = $p['parents'];
  $host = $parent;
  if (count($parents) < $or_count) {
    $removed = end($p['removed']);
    if ($parents[0]['host_entity'] === $removed
      ->getEntityTypeId()) {
      $host = end($p['removed']);
    }
  }
  $parents = array_filter($parents, function ($item) {
    return isset($item['host_entity']);
  });
  $first = NULL;
  foreach ($parents as $parent_item) {
    $host = $this
      ->createParagraph($parent_item['host_field'], $parent_item['bundle'], $host);
    if (!isset($first)) {
      $first = $host;
    }
  }
  return $first;
}