You are here

public static function FieldTargetBase::targets in Feeds 8.3

Returns the targets defined by this plugin.

Parameters

\Drupal\feeds\TargetDefinitionInterface[] $targets: An array of targets.

\Drupal\feeds\FeedTypeInterface $feed_type: The feed type object.

array $definition: The plugin implementation definition.

Overrides TargetInterface::targets

1 method overrides FieldTargetBase::targets()
UserRole::targets in src/Feeds/Target/UserRole.php
Returns the targets defined by this plugin.

File

src/Plugin/Type/Target/FieldTargetBase.php, line 40

Class

FieldTargetBase
Helper class for field mappers.

Namespace

Drupal\feeds\Plugin\Type\Target

Code

public static function targets(array &$targets, FeedTypeInterface $feed_type, array $definition) {
  $processor = $feed_type
    ->getProcessor();
  if (!$processor instanceof EntityProcessorInterface) {
    return $targets;
  }
  $field_definitions = \Drupal::service('entity_field.manager')
    ->getFieldDefinitions($processor
    ->entityType(), $processor
    ->bundle());
  foreach ($field_definitions as $id => $field_definition) {
    if (isset($targets[$id])) {
      continue;
    }
    if ($id === $processor
      ->bundleKey()) {
      continue;
    }
    if (in_array($field_definition
      ->getType(), $definition['field_types'])) {
      if ($target = static::prepareTarget($field_definition)) {
        $target
          ->setPluginId($definition['id']);
        $targets[$id] = $target;
      }
    }
  }
}