You are here

public function Mapper::getTargets in Feeds Paragraphs 8

Parameters

string $entityType:

string $bundle:

Return value

FieldConfigInterface[]

File

src/Mapper.php, line 49

Class

Mapper

Namespace

Drupal\feeds_para_mapper

Code

public function getTargets($entityType, $bundle) {
  $paragraphs_fields = $this
    ->findParagraphsFields($entityType, $bundle);
  $fields = array();

  // Get sub fields for each paragraph field:
  foreach ($paragraphs_fields as $paragraphs_field) {
    $subFields = $this
      ->getSubFields($paragraphs_field);
    $fields = array_merge($fields, $subFields);
  }

  // Remove the fields that don't support feeds,
  // and add some info on the supported fields:
  $definitions = $this->targetsManager
    ->getDefinitions();
  $supported = array();
  foreach ($fields as $field) {
    foreach ($definitions as $name => $plugin) {
      if (in_array($field
        ->getType(), $plugin['field_types'])) {
        $this
          ->updateInfo($field, "plugin", $plugin);
        $this
          ->updateInfo($field, "type", $field
          ->getType());
        $supported[] = $field;
        break;
      }
    }
  }
  return $supported;
}