You are here

protected function Mapper::isWrapped in Feeds Paragraphs 8

1 call to Mapper::isWrapped()
Mapper::getSubFields in src/Mapper.php

File

src/Mapper.php, line 153

Class

Mapper

Namespace

Drupal\feeds_para_mapper

Code

protected function isWrapped(&$sub_field, $first_host) {
  $wrapped = isset($sub_field->target_info);
  if (!$wrapped) {
    return false;
  }
  $path = $this
    ->buildPath($sub_field, $first_host);
  $duplicates = 0;
  foreach ($path as $i => $new_path) {
    if (isset($sub_field->target_info->path[$i]) && $sub_field->target_info->path[$i]['bundle'] === $new_path['bundle']) {
      $duplicates++;
    }
  }
  $wrapped = $duplicates == count($sub_field->target_info->path);
  if (!$wrapped) {
    unset($sub_field->target_info);
  }
  return $wrapped;
}